#C6491. Digit Summation Replacements

    ID: 50257 Type: Default 1000ms 256MiB

Digit Summation Replacements

Digit Summation Replacements

Given a non-negative integer \(X\), repeatedly replace \(X\) by the sum of its digits until it becomes a single-digit number. In each iteration, compute \(X = \sum_{d \in digits(X)} d\) and count the replacement. The task is to determine the number of replacements required to reduce \(X\) to a single-digit number.

Example:

  • If \(X = 57\), then the first replacement gives \(5+7 = 12\) and the second replacement gives \(1+2 = 3\). Hence, the answer is 2.

inputFormat

The first line of input contains an integer \(T\), the number of test cases. Each of the next \(T\) lines contains a non-negative integer \(X\).

outputFormat

Output \(T\) lines, each containing the number of replacements required to reduce the corresponding integer \(X\) to a single-digit number.

## sample
1
5
0

</p>