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
|Added by:||Adrian Kosowski|
|Cluster:||Cube (Intel Pentium G860 3GHz)|
|Languages:||All except: NODEJS PERL 6 SCM chicken|
my code is showing coorect output still it is showing wrong answer
Jesus E. Larios Murillo:
Okay for those people coding in c. I have been taught that the correct way of getting input is to use fgets(buffer, buffer_size, stdin). This avoids overflows. This brings in the new line character also, so I follow it by buffer[strlen(buffer) - 1) = '\0', to get rid of it. This is what I tried to do with this problem, and I have spent HOURS trying to figure out why it doesn't work, even though everything seems right. Finally, serendipitously, I changed the fgets to scanf("%s", buffer), and the code that was not passing before is now passing. I have no words to describe this feeling. Can someone tell me why fgets doesn't work?
This shows WA all the time. Hours of effort for nothing.
after 3 WA finally got green AC , there is no great feeling than doing it yourself and debugging it urself also, it sometimes get frustated to debug but when bug is fixed and got AC, then i m on top of da world :)
Getting TLE when compiling the problem. Almost tested for test case my algorithm works fine. I am using python for the problem. How to minimize my time. Any suggestion will welcomed. (I am newbie in python - any helpful syntax??)
How to store a 100000 digit no ??
getting the correct answer of my code on my pc and also on ideone
This problem requires you to take care of so many test cases. There is a possibility of error even when you check for tricky cases like 9,99,100,101 etc. Also do remember answer for single digit numbers will not be 11.