PALIN - The Next Palindrome

no tags 

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.


The first line contains integer t, the number of test cases. Integers K are given in the next t lines.


For each K, output the smallest palindrome larger than K.




Warning: large Input/Output data, be careful with certain languages

Added by:adrian
Time limit:2s-9s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel Pentium G860 3GHz)
Languages:All except: NODEJS PERL 6

hide comments
Archit Joshi: 2015-08-22 21:34:27

my id is 14910474
@adrian getting wa why?
code is totally fine i've tested it for every worst test case

samson_123: 2015-08-19 16:24:13

try for test cases 999 ,9,8238.....

mohitgupta07: 2015-08-18 21:39:25

i knw my answer is correct! its 100% correct and still giving me d WA...its simply annoying me :/

ABHISHEK RAJPUT: 2015-08-17 19:49:10

my code is even working correctly for num>10e6 by using arrays..but it is showing WA.

Last edit: 2015-08-17 19:51:02
irataba: 2015-08-16 22:34:14

Hi, for some unknown reason, exactly the same code produces an AC when using "Python 3 (python 3.4)" and a WA when using "Python3.4 (Python 3.4)".

pengmessi: 2015-08-16 05:13:02

Holy Moly! I changed the compiler from Python 3.4 to Python 3 then got ACed, what's the difference between this 2 compilers?? (I was using input() method for reading a line)

rjenni: 2015-08-12 16:41:20

Finally green! :D

Himanshu Garg: 2015-08-11 15:11:11

Learned new concept....Great Problem.... :)

subhajit321: 2015-08-09 11:35:04

what is the highest input of the test case?

gutsav: 2015-08-06 06:43:13

Last edit: 2015-08-06 09:41:21

Problem's scores 1 vote

Concept difficulty
Concept difficulty 42%
Implementation difficulty
Implementation difficulty 47%
64 1