#P7441. 「EZEC-7」Erinnerung
「EZEC-7」Erinnerung
Problem Description
Little Y and Little Z are both elves living in Arcaea Offline. Little Y has infinitely many fallen leaves, where the value of the -th leaf is . Little Z has infinitely many snowflakes, where the value of the -th snowflake is . After careful observation by Little X, he found that and satisfy special conditions:
$$C_i= \begin{cases} x\times i& (x\times i\le K)\\ -K& \text{otherwise} \end{cases}$$$$E_i= \begin{cases} y\times i& (y\times i\le K)\\ -K& \text{otherwise} \end{cases}$$Little Y and Little Z can perform some operations on these leaves and snowflakes. Each time, they choose one leaf and one snowflake whose sum of values is , and then combine them into a colorful memory (Erinnerung). After that, this snowflake and this leaf disappear, and they cannot be used in later operations.
Little X wants to know the maximum number of operations they can perform.
Input Format
This problem contains multiple test cases.
The first line contains an integer , indicating the number of test cases.
The next lines each contain three non-negative integers .
Output Format
For each test case, output one integer, representing the maximum number of operations. Output the answers for each test case on separate lines.
2
2 3 10
2 4 11
3
2
1
0 0 1
0
Hint
Sample Explanation
For the first test case of Sample 1, the values of the leaves are , and the values of the snowflakes are . In the first operation, choose the -th leaf and the -st snowflake, with sum . In the second operation, choose the -nd leaf and the -nd snowflake, with sum . In the third operation, choose the -th leaf and the -rd snowflake, with sum . Thus, they can perform operations. It is easy to prove that there is no better solution.
For the second test case, two possible operations are: choosing the -th leaf and the -st snowflake, and choosing the -nd leaf and the -nd snowflake.
For Sample 2, all leaves and snowflakes have value , so it is impossible to find a leaf and a snowflake with sum .
Constraints
- Subtask 1 (30 points): .
- Subtask 2 (70 points): No special constraints.
For of the testdata, , , .
Translated by ChatGPT 5