Problem E
Palindromic Password
The IT department at your school decided to change their
password policy. Each password will have to consist of
You realized that, if all of the numbers were palindromes
(same numbers as the original ones if read backwards), you
would have to remember a bunch of
In order to generate your password of
Of course, you would like to automate this process...
Input
The first line of the input contains a single positive
integer
Output
For each six-digit number in the input, output another six-digit number that is closest to it and is also a palindrome. “Closest” in this context means “a number having the smallest absolute difference with the original number”. If there are two different numbers satisfying the above condition, output the smaller one of the two. Remember, no leading zeroes.
Sample Input 1 | Sample Output 1 |
---|---|
2 123321 123322 |
123321 123321 |