Gug is having fun with numbers! He starts off with an original number X, and can choose between the following operations:
Gug repeats this until he is happy, which is when X becomes 0. Given a list of N integers that Gug starts with, determine for each integer Ai, the minimum operations it takes for Gug to be happy.
The first line of input will contain a single integer, N.
The second line of input will contain N integers, representing the array Ai.
The output should contain N lines with one integer each, with the integer on the ith line representing the number of operations it takes for Gug to be happy if he starts with X = Ai.
Subtask 1 (30%): N = 1, 0 ≤ Ai ≤ 1000000..
Subtask 2 (31%): 1 ≤ N ≤ 105, 0 ≤ Ai ≤ 1000000.
Subtask 3 (39%): 1 ≤ N ≤ 105, 0 ≤ Ai ≤ 30000000.
Subtask 4 (0%): Sample Testcases.
5 1 5 3 10 9
1 4 2 4 3
Subtask | Score |
---|---|
1 | 30 |
2 | 31 |
3 | 39 |
4 | 0 |