poj 2196(水题)
#include<iostream> using namespace std; bool spec(int n){ int i,j,s[3],tmp; bool flag = false; tmp = n; s[0] = 0; while(tmp>0){ s[0] += tmp%10; tmp /= 10; } s[1] = 0; tmp = n; while(tmp>0){ s[1] += tmp%16; tmp /= 16; } tmp = n; s[2] = 0; while(tmp>0){ s[2] += tmp%12; tmp /= 12; } if(s[0]==s[1]&&s[1]==s[2])flag = true; return flag; } int main(){ int i,j; for(i=2992;i<10000;i++){ if(spec(i))printf("%d\n",i); } return 0; }