#P1951. [Aboi 2077] SL2(Z/NZ)
[Aboi 2077] SL2(Z/NZ)
Description
Count the number of matrices with determinant equal to modulo .
That is:
$$\sum_{a=0}^{N-1}\sum_{b=0}^{N-1}\sum_{c=0}^{N-1}\sum_{d=0}^{N-1}[ad-bc\equiv1\ (\bmod\ N)]$$Input Format
Multiple test cases. The first line contains a positive integer indicating the number of test cases.
Then lines follow, each containing a positive integer , the modulus for that test.
Output Format
For each test case, output the answer modulo .
10
2
5
11
23
101
64
128
114514
1919810
1145141919810
6
120
1320
12144
1030200
196608
1572864
173069674
546691096
761755430
Hint
| Subtask ID | Score | |
|---|---|---|
| 1 | 10 | |
| 2 | ||
| 3 | 20 | |
| 4 | ||
| 5 | ||
| 6 |
For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号