水题,暴力可解。
#include <iostream> using namespace std; int chg(int n, int base); int main() { int i; int tmp; for (i=2992; i<10000; i++) { tmp = chg(i, 10); if ( tmp == chg(i, 16) && tmp == chg(i, 12) ) cout <<i<<endl; } } int chg(int n, int base) { int sum = 0; while (n > 0) { sum += n % base; n = n / base; } return sum; }