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
saikiran299:
2020-07-16 08:47:07
k is not <= 1000000
|
|
ip_nandwani:
2020-06-25 20:54:32
i think this is the worst platform i've ever came across.
|
|
Ankur Jain:
2020-06-15 17:35:11
If you're using Java don't use BigInteger for airthmatic operations else it'll raise NZEC or TLE exceptions. |
|
crazybali:
2020-06-01 20:40:05
whenever i post the code it always says runtime error, I'm not getting what does that mean. |
|
chuang:
2020-05-31 11:27:28
My answers are right, but the time exceeds. Is it because I am using c# or my algorithm is not good enough... |
|
yolo129:
2020-05-29 23:28:18
Check for 11, 111,... if you're getting WA even when every other case (in the comments) works! |
|
shubham_0025:
2020-05-27 17:44:20
I am getting all correct answer, I need more test cases can anyone help?
|
|
jmwtechnomage:
2020-05-25 23:23:44
I get an NZEC error, and it's very hard to reproduce. I'm using a fuzzer called 'zuff' and to produce an NZEC with my million line file, I have to set the ratio to something like 1 in 10 bytes being bad, whereupon I get an error from data falling outside of the utf-8 range. I could maybe fix that by telling SBCL not to use UTF-8 somehow (maybe setting it to ascii?) but this appears to be well outside the scope of the problem we are given. We are not told whether data is in ascii or UTF-8, we are not told the format of the files used for the inputs (windows style EOF maybe?).
|
|
surfeyone:
2020-05-24 00:26:44
0 -> 1
|
|
kauai68:
2020-05-17 16:48:29
There are no leading zeros. |
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 |