#P11009. 『STA - R7』求和
『STA - R7』求和
Problem Description
Lloyd has a positive integer , with the initial value or . Each time, he can increase by or by .
Let be the minimum number of operations needed to obtain . If cannot be obtained by operations, then .
Now you are given a positive integer . You need to compute . The answer may be very large, so output it modulo .
Input Format
This problem has multiple test cases.
The first line contains a positive integer , representing the number of test cases.
The next lines each contain a positive integer , describing one query.
Output Format
Output lines, one for each query. Print the answer modulo .
7
1
10
1000000
10000000
1000000000
1000000000000
1000000000000000000
0
16
922782102
752337093
360487662
955916859
689020696
Hint
Constraints:
- Subtask 1 (10 pts): .
- Subtask 2 (30 pts): .
- Subtask 3 (30 pts): .
- Subtask 4 (30 pts): No special constraints.
For all testdata, , .
Translated by ChatGPT 5