#P6511. [QkOI#R1] Quark and Equations
[QkOI#R1] Quark and Equations
Description
Given , find how many pairs of positive integers satisfy the following system of equations:
$$\begin{cases} i+j=n \\ \lfloor\frac{i}{j}\rfloor+\lceil\frac{j}{i}\rceil=m \end{cases}$$In the above, denotes rounding down, and denotes rounding up.
Input Format
This problem contains multiple test cases in a single input file.
The first line contains an integer , indicating the number of test cases.
The next lines each contain two integers , with the meaning as described in the statement.
Output Format
Your output should contain lines.
For each test case, output one integer per line representing your answer.
2
2 2
2 1
1
0
1
6 2
2
Hint
Sample Explanation
When , only satisfies the conditions.
When , there is no solution.
When , only and satisfy the conditions.
Constraints
This problem uses bundled testdata.
- Subtask 1 (10 pts): .
- Subtask 2 (40 pts): .
- Subtask 3 (5 pts): .
- Subtask 4 (5 pts): .
- Subtask 5 (5 pts): .
- Subtask 6 (35 pts): no special constraints.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号