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-03-27 19:03:17 VigneshR
http://ideone.com/******** It shows wrong answer. I have checked all sort of inputs. If anyone point at a test case where it fails would be good. Without knowing what is the issue is makes SPOJ a real frustration. Last edit: 2015-03-29 18:32:17 |
||||||||||||||
2015-03-26 23:45:06 Ilya Tetin
Getting TLE in Java. :( I'm using BufferedReader(new InputStreamReader(System.in)) to read the input character by character, and not expecting a newline at the end. I actually did test it on my local machine with a slower processor with an input file containing multiple integers with 100000 digits , and it finished in split-second. |
||||||||||||||
2015-03-26 14:23:29 Ramesh
i'm using c#.code runs at Ideone.com, but when submit the solution, it gives runtime error.. Please provide the answer for it. I gave the input values in Ideone.com, when submit the solution there is no place to give the input values.. please give the reply for this. Last edit: 2015-03-26 14:24:05 |
||||||||||||||
2015-03-23 20:35:17 Seven.Martinez
Got this using JAVA Last edit: 2015-03-23 22:46:06 |
||||||||||||||
2015-03-16 21:05:20 copperfield
Great problem! |
||||||||||||||
2015-03-16 16:03:32 RFarrell
Why aren't single digit numbers considered palindromes? They should be. Mine kept failing until I forced it to output 11 on any single digit. From wikipedia (http://en.wikipedia.org/wiki/Palindromic_number): "All numbers in base 10 with one digit are palindromic". |
||||||||||||||
2015-03-15 11:06:27 minhthai
very good problem :) |
||||||||||||||
2015-03-07 21:58:12 Manish Mishra
I wrote the program and it works fine and gives the results as expected. But still when I submit it here, it says wrong answer. I can think of the problem. How my program is going to be evaluated? I've assumed that input is entered and then enter key is pressed to get the result. How the inputs are going to be fed? More importantly, how should design my program to be properly fed testcases inputs in here? Please Help Last edit: 2015-03-07 21:59:02 |
||||||||||||||
2015-03-07 11:04:12 Aditya Garg
i dont know why is it showing TLE i gave the inputs myself they were fine |