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
ipepe:
2016-10-10 16:39:13
Why can't I use node for this challenge? |
|
arpan_jain_946:
2016-10-05 11:55:51
For java, I am getting wrong answer, any suggestion???
|
|
vaman_t:
2016-10-01 21:13:44
AC. thanks @vector1996 for test cases Last edit: 2016-10-01 21:15:27 |
|
engineer_9999:
2016-09-30 02:17:00
@narutohokage_1
|
|
anny83:
2016-09-29 07:07:38
I also used python3.4, always got "time limit exceeded" :( |
|
sassy_gourmet1:
2016-09-28 09:56:53
@narutohokage_1 Hey I checked all your test cases except the '000000' one. They work fine but my code still isn't being accepted. What might be the mistake that I am making? |
|
sibo7851:
2016-09-25 18:06:25
My code works flawlessly and is giving exactly the expected output...is there some formatting expectation which would cause it to be marked wrong? |
|
narutohokage_1:
2016-09-25 07:39:08
@malavan , the input file will not contain 00000 as it is not the correct input. You do not have to think about it. If you think for other things ignoring this then when someone does input 00000 then answer will automatically come 00100 . We do not have to think about it. I know it is i guess voilating principle so it would not be in test case. |
|
malavan:
2016-09-24 15:45:02
@narutohokage_1 ip 00000 op 00100... is not violating the principle of palindrome ???
|
|
narutohokage_1:
2016-09-24 13:06:20
For All People Who Are Getting WRONG ANSWER MANY Times....
|
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 |