杭电 hdu 2097

Sky数:

#include<iostream>
using namespace std;
int Judge(int n,int m){
    int sum=0;
    while(n){
        sum+=n%m;
        n/=m;
    }
    return sum;
}
int main(){
    int n;
    while(cin>>n&&n){
        if(Judge(n,10)==Judge(n,16)&&Judge(n,10)==Judge(n,12))
            cout<<n<<" is a Sky Number."<<endl;
        else
            cout<<n<<" is not a Sky Number."<<endl;
    }
    return 0;
}


你可能感兴趣的:(ACM,HDU,杭电,2097)