Description
This problem is a programming version of Problem 55 from projecteuler.net
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
Not all numbers produce palindromes so quickly. For example,
349 + 943 = 1292
1292 + 2921 = 4213
4213 + 3124 = 7337
That is, 349 took three iterations to arrive at a palindrome.
(i) become a palindrome in less than 60 iterations, or,
(ii) no one, with all the computing power that exists, has managed so far to map it to a palindrome.
Now we see that a lot of numbers converge to the same palindrome, for example
[19,28,29,37,38,46,47,56,64,65,73,74,82,83,91,92,110,121] all converge to 121, a total of 18 numbers.
Note: For this problem we have assumed palindrome numbers like 55,121 to be non-lychrel in 0th iteration.
Given N, find the palindrome to which maximum numbers ∈ [1,N]converge. Print the palindrome and the count.
Input Format
Input contains an integer N
Output Format
Print the answer corresponding to the test case.
Constraints
5
100 ≤ N ≤ 10
Sample Input
Sample Output




Reviews
There are no reviews yet.