Problem Descriptionsky from childhood like strange things, and is born particularly sensitive to the number, an accidental opportunity, he found an interesting four-digit 2992, this number, its decimal number, its four-digit sum of 2+9+9+2=22, its hexadecimal number BB0 , its four-digit sum is also 22, at the same time its 12 binary number means 1894, its four-digit sum is 22, ah ha, really clever ah. Sky is very fond of this four-digit number, because of his discovery, so here we name it as Sky number. But to judge such a number is still a bit of trouble ah, so now please help to judge any decimal four digits, is not the sky number bar.
The input input contains some four-bit positive integers, and if 0, the entry ends.
Output "#n is a sky number if n is sky.", otherwise the output "#n is not a sky numbers." Each result occupies one row. Note: #n表示所读入的n值.
Sample Input299212340
Sample Output2992 is a Sky number.1234 are not a sky number.
Source2007 Provincial Training Team Practice (2)
Recommendlcy | We have carefully selected several similar problems for you:2095 2089 2094 2093 1406
1#include <iostream>2 using namespacestd;3 4 intSum_k (intNintk)5 {6 ints=0;7 while(n!=0)8 {9s+=n%K;TenN/=K; One } A returns; - } - the intMain () - { - intN; - while(cin>>n,n!=0) + { - inta,b,c; +A=sum_k (N,Ten); AB=sum_k (N, A); atC=sum_k (N, -); - if(a==b&&a==c) -cout<<n<<"is a Sky number."<<Endl; - Else -cout<<n<<"Is isn't a Sky number."<<Endl; - } in return 0; -}
Sky Number 2097