luogu#P7847. 「dWoi R2」Elevator / 电梯
「dWoi R2」Elevator / 电梯
Background
Zszz, the main character always writes a little essay in their mind while taking the elevator down before the class trial.
But what if they cannot write anything? Zzz ......
So Saihara started thinking about math problems ......
Problem Description
There are positive integers satisfying the equation: , and .
Given a positive integer , write a program to compute the number of equations with , and output one that satisfies the following condition:
Among all equations with , choose one with the smallest .
Input Format
The first line contains a positive integer , the number of queries.
The next lines each contain one positive integer, the given .
Output Format
Output lines. Each line contains a positive integer, the number of equations that satisfy the condition. If a solution exists, output a space and then output one valid .
It can be proven that when , such a always exists.
2
1
2
0
1 2
2
233
2020
479 54056
5470 8181
Hint
Sample #2 Explanation
In the first query, the corresponding equation is: , so the second output is .
In the second query, the corresponding equation is: $\dfrac{1}{1620} - \dfrac{1}{8181} = \dfrac{1}{2020}$, so the second output is .
And in these two equations, is the smallest among all cases with .
Constraints
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
About Special Judge
This problem uses Special Judge.
If you answer the first question all correctly but make mistakes on the second question, you will get of the score. If you answer the first question incorrectly but answer the second question all correctly, you will get of the score. However, if both the first and the second questions have some or all wrong answers, you will be judged as WA. Also, if your output is incomplete or has extra parts, for example, you only answer the first question but do not output the answer for the second question (except when ), or you output one extra number when , then you will also get no score.
Translated by ChatGPT 5