标签:
就是简单的求出各进制之和,比较是否相等就好了
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 20822 Accepted Submission(s):
11865
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; } }
标签:
原文地址:http://www.cnblogs.com/cwenliu/p/5764525.html