#P8319. 『JROI-4』分数
『JROI-4』分数
Description
The process of an “-person petition” can be seen as a function :
There is a fraction . Repeat the following steps until this fraction becomes :
- Add to the numerator.
- If this fraction can be reduced, reduce it to its simplest form.
Now Xiao D gives you test cases. In each test case, you are given . You need to find, for , the maximum number of operations of .
But he is too weak and cannot do it. Can you help him?
Input Format
The first line contains a positive integer .
The next lines each contain a positive integer .
Output Format
Output lines. Each line contains an integer , meaning the maximum number of operations of for .
5
1
2
5
8
114514
1
2
5
7
114493
Hint
Sample Explanation
.
I also want to list larger values of , but there is not enough space.
Constraints
For all testdata, , .
Parts not filled in the Subtasks table mean they are the same as the constraints for all data.
| Subtask ID | Range of | Range of | Special Property | Score |
|---|---|---|---|---|
| Subtask | ||||
| Subtask | ||||
| Subtask | is prime. | |||
| Subtask | ||||
| Subtask |
Translated by ChatGPT 5
京公网安备 11011102002149号