#P1207. [USACO1.2] Dual Palindromes
[USACO1.2] Dual Palindromes
题目背景
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 ).
题目描述
A number that reads the same from right to left as when read from left to right is called a palindrome. The number is a palindrome; the number is not. Palindromes have neither leading nor trailing zeroes, so is not a palindrome.
The number (base ) is not a palindrome in base , but the number (base ) is a palindrome in base ().
Write a program that reads two numbers expressed in base :
- ()
- ()
Then find and print (in base ) the first numbers strictly greater than that are palindromic when written in two or more number bases ().
Solutions to this problem do not require manipulating integers larger than the standard bits.
输入格式
A single line with space separated integers and .
输出格式
lines, each with a base number that is palindromic when expressed in at least two of the bases . The numbers should be listed in order from smallest to largest.
3 25
26
27
28
提示
USACO Training Section 1.2.