#P6610. [Code+#7] 同余方程
[Code+#7] 同余方程
Description
These are some naive quadratic congruence equations.
Given several groups of positive integers and , find the number of solution pairs to the equation with respect to and modulo , where is odd and has no square factors.
Input Format
The first line contains a positive integer , indicating the number of queries.
The next lines each contain two positive integers and separated by a space. It is guaranteed that , is odd, and for any odd prime , we have .
Output Format
Output lines. The -th line contains a positive integer, indicating the number of solution pairs for the -th equation.
1
5 0
9
Hint
Sample Explanation
The solution pairs are $(a,b) = (0,0),(1,2),(1,3),(2,1),(2,4),(3,1),(3,4),(4,2),(4,3)$.
Subtasks
Each test point is worth points.
For all testdata, , , and , odd primes , .
| Test Point ID | Additional Property | ||
|---|---|---|---|
| is an odd prime | |||
| is an odd prime | |||
| is an odd prime | |||
| is an odd prime | |||
Translated by ChatGPT 5
京公网安备 11011102002149号