main.cpp 376 B

123456789101112131415161718192021
  1. #include <iostream>
  2. using namespace std;
  3. int trans(int i, int base) {
  4. int result = 0;
  5. for (; i;) {
  6. result += i % base;
  7. i /= base;
  8. }
  9. return result;
  10. }
  11. int main() {
  12. for (int i = 2992; i <= 9999; i++) {
  13. if (trans(i, 10) == trans(i, 12) && trans(i, 10) == trans(i, 16)) {
  14. cout << i << endl;
  15. }
  16. }
  17. return 0;
  18. }