boolisPalindrome(string str){ for (int i = 0, j = str.size() - 1; i < j; ++i, --j) { if (str[i] != str[j]) returnfalse; }
returntrue; }
stringgetNumber(int number, int BASE){ string str; int base = BASE; while (number) { int digit = number % base; int factor = base / BASE; digit /= factor; str.push_back(digit + '0'); number -= digit * factor; base *= BASE; }
for (int i = S + 1, j = 0; j < N;) { int count = 0; for (int k = 2; k <= 10; ++k) { if (j > N) break; string num = getNumber(i, k); if (isPalindrome(num)) { ++count; if (count == 2) { fout << i << std::endl; ++j; ++i; break; } } }