luogu#P1207. [USACO1.2] 双重回文数 Dual Palindromes
[USACO1.2] 双重回文数 Dual Palindromes
Background
If a number reads the same from left to right and from right to left, then it is called a "palindrome." For example, is a palindrome, while is not. We do not allow leading zeros in the representation; therefore, is not considered a palindrome.
In fact, some numbers (such as ) are not palindromes in base , but they are palindromes in other bases (for example, in base it is ).
Problem Description
Given two decimal integers , find the first decimal numbers greater than that are palindromic in at least two bases among base through base , and output them.
A solution to this problem does not need integers wider than bits.
Input Format
One line containing two positive integers separated by a space.
Output Format
Output lines. Each line contains one number that satisfies the requirement, in ascending order.
3 25
26
27
28
Hint
Constraints
For of the testdata, , .
Problem translation from NOCOW.
USACO Training Section 1.2.
Translated by ChatGPT 5