#P6736. 「Wdsr-2」白泽教育
「Wdsr-2」白泽教育
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
One line contains four integers .
Output Format
For each test case, output one line with one integer. If the original equation has a solution, output the smallest non-negative integer solution; otherwise, output .
3
2 1 1 3
3 1 2 7
7 1 2 4
0
2
-1
3
2 2 4 7
3 2 4 6
5 2 1 3
2
-1
0
3
4 3 5 8
2 3 9 11
6 3 1 5
-1
3
0
Hint
This problem uses bundled evaluation.
| Subtask | Score | Time Limit | |||
|---|---|---|---|---|---|
| and is prime | |||||
| No special constraints | |||||
| No special constraints |
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号