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
|
||||||||||||||
2016-01-31 20:16:38 Vivek Mangal
My code is working fine for any input I enter, but spoj is showing WA. Is my algo wrong?(id=16204230) |
||||||||||||||
2016-01-28 20:55:23
nvm, solved my problem. i just had to change my loop-iterators to int64_t's instead of normal int's haha ;D |
||||||||||||||
2016-01-28 20:45:16
I whish spoj would show which test-cases i got wrong answer on, would make bug-finding much easier. i mean if i run the computer manually, all of the test-cases i can think off give me the correct answer..... |
||||||||||||||
2016-01-26 17:07:25
for those who r getting wrong answer and are sure about there program just put a next line or endline after each cout and cin statements.Maybe this works it WORKED for me |
||||||||||||||
2016-01-26 17:05:47
hey guys i just solved the problem. The only problem i got wrong answers 10 times was the next line i checked my program alot but suddenly i solved some problems and got a concept to put a next line character after each cout and in statement and the same program run successfully |
||||||||||||||
2016-01-25 04:50:25
"given positive integer K of not more than 1000000 digits", this really means a number with 1_000_000 digits???? |
||||||||||||||
2016-01-22 17:13:32 sri
Solved after 1 year..... see the algorithm in geeks learnt a new thing |
||||||||||||||
2016-01-21 00:35:41
This problem is quite simple to solve. Haskell's String ( [Char] ) is unusable for this - you'll get TLE. Use ByteString which has O(1) for important functions such as last, drop, take, length (where [Char] has O(n)) |
||||||||||||||
2016-01-17 15:09:04
TLE error for no good reason :( |
||||||||||||||
2016-01-10 16:13:05
1000000 digits could be a reason for NZEC runtime error. |