#K90877. Symmetrical Number Transformation

    ID: 37850 Type: Default 1000ms 256MiB

Symmetrical Number Transformation

Symmetrical Number Transformation

You are given a positive integer n. Your task is to transform this number into a symmetrical (palindromic) number by repeatedly adding the reverse of the number to itself. A number n is said to be palindromic if it satisfies \(n = \text{reverse}(n)\), where \(\text{reverse}(n)\) denotes the integer obtained by reversing the decimal digits of n.

The process is as follows:

  1. If n is already a palindrome, the process stops immediately.
  2. Otherwise, compute \(r = \text{reverse}(n)\), then update \(n = n + r\) and increment the step counter.
  3. Repeat the process until n becomes palindromic.

Output the number of steps taken and the resulting palindromic number.

Note: Ensure that your program reads input from standard input (stdin) and writes output to standard output (stdout).

inputFormat

The input consists of a single line containing a positive integer n.

Example:

56

outputFormat

Output two integers separated by a space: the number of steps required and the resulting palindromic number.

Example:

1 121
## sample
1331
0 1331