hdu 2097 Sky数
2012-08-09 17:43
197 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2097
进制转换类型的题
进制转换类型的题
#include <iostream> using namespace std; int test(int n,int hex){ int sum=0; while(n){ sum+=n%hex; n=n/hex; } return sum; } int main() { int n; while(cin>>n&&n){ if((test(n,10)==test(n,16))&&(test(n,12)==test(n,16))) cout<<n<<" is a Sky Number."<<endl; else cout<<n<<" is not a Sky Number."<<endl; } return 0; }