Submit | All submissions | Best solutions | Back to list |
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
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 |
hide comments
|
||||||||||||||
2015-04-24 20:37:02 Gaurav Agarwal
I cant figure out the test cases... can someone give me the outputs for the following input? 7 //no of test cases 5 8 9 20 98 998 6436 |
||||||||||||||
2015-04-23 18:57:41
Single digit number is not a palindrom. It means if i enter 6 it must give 11 as output.is that right?? Or it should be 7 Last edit: 2015-04-23 19:08:07 |
||||||||||||||
2015-04-20 22:42:28 Szymon
nice problem for tests coding 1 do brute force program 2 do your algorithm 3 compare results |
||||||||||||||
2015-04-20 20:49:43 ashish
Hello admin/problem setter, can you please check why I am a getting wrong answer? Id: 14128402 Also can you please give at-least 1 testcase where I am getting a wrong answer? |
||||||||||||||
2015-04-19 16:32:41 Anakar Parida
I am also fed up with wrong solution. Handled all cases from 1 to 999999999999999999. Dont know what else is needed |
||||||||||||||
2015-04-19 15:49:39 Eknoor Jassal
I would restate what everyone is saying. I not " all about nines". Its about "all nines" ;) |
||||||||||||||
2015-04-18 19:46:17 Anakar Parida
One small suggestion for all people who are facing "wrong answer".. Single digit number is not palindrome. Do make sure your code handles it. |
||||||||||||||
2015-04-17 21:57:10
i have tried this code for every case yet it says wrong answer.Please list the difference test cases.....ughh i am fed up with this one |
||||||||||||||
2015-04-16 18:36:46 saki
Guys i am new to SPOJ, not sure where to post my source code so that someone can check why it is showing wrong answer, I got exact o/p as mentioned in the question when done in Putty. Please help! |
||||||||||||||
2015-04-14 12:30:51
it works fine on code blocks but on the site its shows wrong answer. Guys please help. |