Advertisement blocking software were detected ;( Please add this webpage to whitelist.

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.


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

hide comments
Vaibhav Malik: 2015-10-06 21:00:24

AC in One GO . . . . .

ankitch6: 2015-10-05 23:21:54

ac in first attempt....:)

farmers_rice: 2015-10-03 02:42:47

I am getting a runtime error NZEC but the program works fine on my computer and in ideone. The only places an exception can possibly occur are in input.

Last edit: 2015-10-09 02:49:58
dungen_master: 2015-09-30 15:42:12

getting error time limit exceed!!
any suggestions?

mihirs745: 2015-09-26 13:02:55

Very good question but in my case it shows time limit exceeded.Some one please help me and check my code its in C

nguyễn vãn lâm: 2015-09-23 18:49:02

the only once, accepted!..

Last edit: 2015-09-23 19:29:01
nishaagg: 2015-09-13 18:48:20

I am also getting NZEC error...

Dushyant Singh: 2015-09-12 14:03:43

@almas - because we have to find next palindrome. 2112<2133 and 2133<2222.

Almas: 2015-09-12 11:54:31

For the second case why output can't 2112 which is less than 2222?

tiwariayan: 2015-09-11 17:38:31

tried like some 500 test cases
still WA in java
someone help please

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

Problem's scores 1 vote

Concept difficulty
Concept difficulty 42%
Implementation difficulty
Implementation difficulty 47%
71 3