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-06-10 20:28:06
ok. this problem is really frustating. 1. I'm using brute force, so answer has to be correct.(no issues for 9's or whatever) 2. I'm not using strings, so no problem for leading zeroes. 3. Tried both cases for single digit integers(11 and next digit). 4. Tried removing new line character at the end. 5. Using long int in C. What else shall I try to remove this WA!!! |
||||||||||||||
2015-06-10 20:25:11
getting wrong answer...can someone give me sample data to cross check my code.. |
||||||||||||||
2015-06-10 10:01:50
getting runtime error (SIGXFSZ) i don't know why no extra space other than char array are used; |
||||||||||||||
2015-06-10 08:41:46
successfully works on ideone as well as my system..however, here it always shows the "Wrong answer" error..don't know what to do! any help! |
||||||||||||||
2015-06-09 09:00:25
how large are their test cases, running perfectly on my system, showing wrong answer here...plz help and about single digit numbers i think next palindrome should not be 11 for all the cases Last edit: 2015-06-09 09:02:10 |
||||||||||||||
2015-06-05 07:31:50
2 comments below me is wrong ,question is correct. Last edit: 2015-06-05 07:32:52 |
||||||||||||||
2015-06-02 20:43:13
getting sigsegv error..... Its running fine on my device... |
||||||||||||||
2015-05-31 05:43:34 Alex Reimann Cunha Lima
Unfortunately this problem is WRONG! Single digits ARE palindromes (source: http://en.wikipedia.org/wiki/Palindromic_number), but you will keep getting WA until you make sure to print "11" whenever the input is a single digit. |
||||||||||||||
2015-05-30 21:49:36
please check it......tried everything <snip> Last edit: 2022-07-26 22:23:22 |
||||||||||||||
2015-05-29 16:04:34 Guruvamsi
this site is pathetic when it comes to dealing with wrong formats this is what makes me want to quit |