Submit | All submissions | Best solutions | Back to list |
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
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 |
hide comments
|
||||||||||||||
2016-02-21 20:27:32
is it possible in spoj to know for which input values the code is going wrong?? reply asap . |
||||||||||||||
2016-02-21 07:07:31
I am getting wrong output but it is working correctly.My solution id is 16329198. |
||||||||||||||
2016-02-20 17:56:25
did in 1 go :) .....here are some test cases which might help you to find bugs i/p 12345 14325 12325 52321 12945 12925 99998 99999 98999 89999 4 8 231 132 268545813 208545813 2862 2682 2221 1222 2993 o/p 12421 14341 12421 52325 13031 13031 99999 100001 99099 90009 5 9 232 141 268545862 208555802 2882 2772 2222 1331 3003 |
||||||||||||||
2016-02-16 20:10:20 Ankit
Accepted at 1st attempt. :D |
||||||||||||||
2016-02-14 11:19:13 Lyndon Michael Bibera
clue: 1.) store and manipulate the input as string. 2.) brute-forcing == dumb |
||||||||||||||
2016-02-11 14:08:48 Payal
worth doing ! |
||||||||||||||
2016-02-09 15:25:49
Accepted on 1st attempt :) I feel like I am GENIUS. |
||||||||||||||
2016-02-06 00:32:27 Julian Leyh
NZEC = Non Zero Error Code, in this case most likely your program can't handle large input numbers (up to one million digits). |
||||||||||||||
2016-02-05 05:54:39
hello guys what does NZEC means ?? My code is working in my machine and I try the test cases that I've read in the comments and the answers are correct. Thank you |
||||||||||||||
2016-02-03 18:47:48 Tony Stark
Firstly depressed...but finally enjoyed this question |