杭电2097
1 #include<stdio.h> 2 3 int main() 4 { 5 int jz(int n,int r); 6 int t,x,n; 7 while(~scanf("%d",&n)&&n) 8 { 9 x=n/1000+n/100%10+n/10%10+n%10; 10 //printf("x=%d\n",x); 11 t=jz(n,16); 12 //printf("t1=%d\n",t); 13 if(t!=x) 14 { 15 printf("%d is not a Sky Number.\n",n); 16 continue; 17 } 18 t=jz(n,12); 19 //printf("t2=%d\n",t); 20 if(t!=x) 21 printf("%d is not a Sky Number.\n",n); 22 else 23 printf("%d is a Sky Number.\n",n); 24 } 25 } 26 27 int jz(int n,int r) 28 { 29 int i=0,s=0,t=1; 30 while(t<=n) 31 t*=r; 32 t/=r; 33 while(t!=1) 34 { 35 s+=n/t%r; 36 t/=r; 37 } 38 s+=n%r; 39 return s; 40 }