|
digits-3
We perform the following operation on a positive integer: we sort its
digits in ascending order — removing any leading zeros — then subtract
the product of its digits from that number. For example:
3213210 ⟶ 0112233 ⟶ 112233-36 = 112197 We repeat this
process with each resulting number until we get zero:
1231230 ⟶ 112197 ⟶ 111153 ⟶ 111120 ⟶ 11110 ⟶ 1110 ⟶ 110 ⟶ 10 ⟶ 0
How many steps does it take to reach zero? What is the maximum
number of steps
()
for all integers in an interval
?
Input specification
The first line contains
,
the number of test cases. Then
lines follow, each containing the numbers
and
.
Output specification
Output
lines, each containing the required value
.
Constraints
Solving smaller subtasks will yield partial points.
Sample input 1
51 99100 999910000 1000001231230 123321056875687 56875687
download as text file
Sample output 1
411131311
download as text file
|
|