Inside OutProblem code: CYW12 |
The reverse and add function starts with a number, reverses its digits, and adds the reverse to the original. If the sum is not a palindrome (meaning it does not give the same number read from left to right and right to left), we repeat this procedure until it does. For example, if we start with 195 as the initial number, we get 9,339 as the resulting palindrome after the fourth addition: 195 786 1,473 5,214 591 687 3,741 4,125 + + + + 786 1,473 5,214 9,339 This method leads to palindromes in a few steps for almost all of the integers. But there are interesting exceptions. 196 is the first number for which no palindrome has been found. It has never been proven, however, that no such palindrome exists. You must write a program that takes a given number and gives the resulting palindrome (if one exists) and the number of iterations/additions it took to find it. You may assume that all the numbers used as test data will terminate in an answer with less than 1,000 iterations (additions), and yield a palindrome that is not greater than 4,294,967,295.
Input
The first line will contain an integer N (0 < N 100), giving the number of test cases, while the next N lines each contain a single integer P whose palindrome you are to compute.
| Author: | arnavch |
| Date Added: | 20-03-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | C, C99 strict, CLOJ, CPP 4.0.0-8, CPP 4.3.2, F#, GO, PERL6, PYTH 3.1.2, TEXT |
Comments

Fetching successful submissions

what should be the format of
what should be the format of output?
You just have to display the
You just have to display the answer nothing else required....
Againmsubmission is not
Againmsubmission is not possible ?!!
So send us ur entries
So send us ur entries alongwith ur id to codechef1@gmail.com