408774: GYM103306 I Integer Multiplicative Persistence

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Integer Multiplicative Persistencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

In mathematics, the persistence of a number is the number of times one must apply a given operation to an integer before reaching a fixed point at which the operation no longer alters the number. The multiplicative persistence of an integer, is how often one has to replace the number by the product of its digits until one reaches a single digit. For example, the multiplicative persistence of 39 is 3, because it takes three steps to reduce 39 to a single digit, in the first step the operation is $$$3*9 = 27$$$, in the second step the operation is $$$2*7 = 14$$$, and the third and last step is $$$1*4 = 4$$$.

Your task for this problem is given a number $$$N$$$, find its multiplicative persistence.

Input

The first line of input contains a single integer $$$T$$$ ($$$1 \leq T \leq 1000$$$), representing the number of test cases in the input. Each of the next $$$T$$$ lines contains a single integer $$$N$$$ ($$$0 \leq N \leq 10^9$$$), representing the value $$$N$$$ to which the multiplicative persistence should be found.

Output

For each test case in the input output a line containing one integer number, the multiplicative persistence of $$$N$$$.

ExampleInput
6
0
5
10
25
39
27
Output
0
0
1
2
3
2

加入题单

算法标签: