题目
http://acm.hdu.edu.cn/showproblem.php?pid=2097
思路
既然要求和 十进制数字各个位数上的和是相同的, 那么16,12进制转换完之后也是10进制表示的
#include <iostream> #include <queue> #include <cstdio> #include <cstring> #include <cstdlib> #include <stack> using namespace std; #define maxn 15000int Sky(int n,int k) { int num = 0; while(n) { num += n%k; n /= k; } return num; } int main() { int n; while(cin >> n, n) { int a = Sky(n,10); int b = Sky(n,12); int c = Sky(n,16); if(a == b && b == c) printf("%d is a Sky Number. ",n); else printf("%d is not a Sky Number. ",n); } return 0; }