标签:
如果一个数字 十进制的各位数的和 == 十六进制的各位数的和 == 十二进制的各位数的和,则输出,从2992到9999
#include <cstdio> int toDD(int n) { int sum = 0; while(n) { sum += n%12; n /= 12; } return sum; } int splitSum(int n) { int sum = 0; while(n) { sum += n%10; n /= 10; } return sum; } int toHex(int n) { int sum = 0; while(n) { sum += n % 16; n /= 16; } return sum; } int main() { int i,n; for(i = 2992; i < 10000; ++i) { if((n = splitSum(i)) == toHex(i) && n == toDD(i)) printf("%d\n",i); } return 0; }
poj 2196 Specialized Four-Digit Numbers
标签:
原文地址:http://www.cnblogs.com/guoyongheng/p/5722502.html