PALIN - The Next Palindrome
A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros.
Input
The first line contains integer t, the number of test cases. Integers K are given in the next t lines.
Output
For each K, output the smallest palindrome larger than K.
Example
Input: 2 808 2133 Output: 818 2222
Warning: large Input/Output data, be careful with certain languages
hide comments
AbuGasem:
2015-05-07 13:10:46
<snip>
|
|
baby_monk:
2015-05-05 23:42:27
@adrian: Can you let me know which test this is <snip> Last edit: 2022-07-26 22:29:34 |
|
sksuman.nitw:
2015-05-04 19:36:08
finally accepted.....
|
|
sanlocoz:
2015-05-03 04:20:13
<snip> Last edit: 2022-07-26 22:29:30 |
|
chazshiz:
2015-05-02 21:05:47
i got 21s base on 100,000, how can i do for 1,000,000? |
|
Anakar Parida:
2015-04-28 18:04:21
I am able to pass wrong answer but now getting time limit exceeded :(
|
|
shomit:
2015-04-25 11:29:33
Dont know about 5 and 8 as Anakar sugested below that 1 digit number r not palindrime.for 9 20 98 998 6436 are 11 22 99 999 6446 |
|
Gaurav Agarwal:
2015-04-24 20:37:02
I cant figure out the test cases...
|
|
shomit:
2015-04-23 18:57:41
Single digit number is not a palindrom. It means if i enter 6 it must give 11 as output.is that right?? Or it should be 7 Last edit: 2015-04-23 19:08:07 |
|
Szymon:
2015-04-20 22:42:28
nice problem for tests coding
|
Added by: | adrian |
Date: | 2004-05-01 |
Time limit: | 2s-9s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS PERL6 |