返回列表 發帖
/**********************************************************************************/
/*  Problem: d593 "F. 生命靈數" from 2009 NPSC 國中組初賽                */
/*  Language: CPP (483 Bytes)                                                     */
/*  Result: AC(4ms, 384KB) judge by this@ZeroJudge                                */
/*  Author: ray0410 at 2011-11-12 23:35:34                                        */
/**********************************************************************************/


#include<iostream>
using namespace std;

int main()
{
    int magic,number,total;
    cin >> total;
    while(total>0)
    {
      cin >> number;
      do
      {
         magic = 0;
         while(number>0)
         {
           magic += number % 10;
           number = number / 10;
         }
         number = magic;
      }
      while(magic > 9);
      cout << magic << ", " << (magic==2?"Yes":"No") << endl;
      total--;
    }

    return 0;
}

TOP

返回列表