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
tweakmonkey:
2024-09-29 22:21:28
For anyone stuck getting wrong answer - try this input:
|
|
carofe82:
2024-08-10 16:16:24
This was a weird problem. @shreyas_07 test cases helped a lot! |
|
puppetmaster:
2024-06-25 10:08:00
was getting wrong answer forever @shreyas_07 tcs saved me |
|
temurjon_01:
2024-03-07 09:55:53
what a fuck is that spoj find another compiler i did anything right and again "WRONG ANSWER". |
|
rayhanulislam:
2023-12-15 17:08:01
how much test case? |
|
dwind11:
2023-11-06 09:18:11
gg
|
|
sleepyslash:
2023-07-02 12:02:44
my code is all fine and working very well in my compiler the same file giving a runtime error in spoj judge why ???
|
|
jmdalida11:
2023-02-16 12:17:09
I solved it using rust <3 |
|
fjkexgnffhwihp:
2022-06-20 17:09:50
Why is the implementation difficulty so high? I found it to be pretty easy in both concept and implementation in CPP14 |
|
paintbucket7:
2022-04-23 21:04:52
If you're getting SIGABRT then it means that you're probably converting the given string to int so you must not do that. You must solve the problem in the string itself as the input is too large.
|
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 |