#K78887. Palindrome Transformation

    ID: 35186 Type: Default 1000ms 256MiB

Palindrome Transformation

Palindrome Transformation

Given a non-negative integer \( n \), transform it into a palindrome by repeatedly reversing its digits and adding the reversed number to the original. Specifically, at each step, compute \( r \), the reverse of \( n \) (i.e. \( r = \text{reverse}(n) \)), and update \( n \) as \( n + r \). The process stops when \( n \) becomes a palindrome (i.e. \( n \) reads the same forwards and backwards). If a palindrome is found within 1000 iterations, output the palindrome and the number of steps taken. Otherwise, output "-1 -1".

Note: A number is considered a palindrome if its string representation is the same when reversed. All arithmetic operations are performed with infinite precision for this problem.

inputFormat

The input is read from standard input and consists of a single non-negative integer ( n ).

outputFormat

Output two space-separated integers: the resulting palindrome and the number of steps taken to reach it. If no palindrome is found within 1000 iterations, output "-1 -1".## sample

87
4884 4