(DS1.5.2)POJ 2196 Specialized Four-Digit Numbers(同意数字各个进制的表示方式)

来源:互联网 发布:mac os x英文操作界面 编辑:程序博客网 时间:2024/04/29 16:48
/* * POJ_2196.cpp * *  Created on: 2013年10月18日 *      Author: Administrator */#include <iostream>#include <cstdio>using namespace std;int n;const int maxn = 17;int a[maxn];void prepare(int x){int temp = n;while(temp != 0){a[x] += temp%x;temp /= x;}}int main(){for(n = 2992 ; n <= 9999 ; ++n){a[16]=a[12]=a[10]=0;prepare(16),prepare(12),prepare(10);if(a[16] == a[12] && a[10] == a[12]){printf("%d\n",n);}}return 0;}