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
eagleshadow:
2018-09-28 19:18:27
AC in one go :) |
|
dworack:
2018-09-19 07:48:53
Wrong answers a few times. After changing fgets to scanf, the same code works well! (language C). |
|
dadhich_01:
2018-09-02 17:55:14
naruto17 read question clearly |
|
eng_hardik:
2018-09-02 07:44:57
A great problem with a variety of test cases , so before careful about all the possibilities. |
|
gvsharma:
2018-08-28 07:10:21
getting time exceeded..
|
|
rajatsahay:
2018-08-25 09:27:05
it says time limit exceeded..ran it on ideone.com and total time taken was 0.04s |
|
naruto17:
2018-08-19 22:02:21
for run time errors ;
|
|
nobody550:
2018-08-04 21:17:51
Check for '9'
|
|
aquib_ansari:
2018-07-15 17:44:49
Do we need to consider -ve numbers as well? |
|
shivansh306:
2018-07-15 12:39:04
Run time error in python3 I am defining a function for solving the problem |
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 |