is simply to find out the sum of the various systems, compare whether the equality is good
Sky number
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 20822 Accepted Submission (s): 11865
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.
Import Java.util.scanner;public class Main {public static void main (string[] args) {Scanner scan = new Scanner (system.in); while (Scan.hasnext ()) { int n=scan.nextint (); if (n==0) break; int s1=f (n,10), S2=f (n,12), s3=f (n,16); if (S1==S2&&S2==S3) System.out.println (n + "is a Sky number."); else System.out.println (n + "is not a Sky number.");} } public static int f (int n,int i) {int s=0;while (n!=0) {s+=n%i;n/=i;} return s;}}
(Java implementation) Hangzhou electric OJ 2097 Sky number