hdu 2097

ps:WA了两次好像....Sky数是三个进制下的各位数之和相等...而不是都等于22...我傻逼了...

代码:

#include "stdio.h"
int inp(int a,int n);
int main(){
    int n,k;
    while(~scanf("%d",&n) && n){
        if(inp(n,16)==inp(n,10) && inp(n,16)==inp(n,12)){
            printf("%d is a Sky Number.\n",n);
        }
        else printf("%d is not a Sky Number.\n",n);
    }
    return 0;
}
int inp(int a,int n){
    int i,k,sum=0;
    while(a/n!=0){
        k=a%n;
        sum+=k;
        a=a/n;
    }
    sum=sum+a;
    return sum;
}

 

你可能感兴趣的:(hdu 2097)