#P7509. [2017年杭电多校]Inverse of sum
[2017年杭电多校]Inverse of sum
Inverse of sum
Problem Description
There are nonnegative integers which are less than . HazelFan wants to know how many pairs are there, satisfying when we calculate module , which means the inverse element of their sum equals the sum of their inverse elements. Notice that zero element has no inverse element.
Input
The first line contains a positive integer , denoting the number of test cases. For each test case: The first line contains two positive integers , and it is guaranteed that is a prime number. The second line contains nonnegative integers .
Output
For each test case: A single line contains a nonnegative integer, denoting the answer.
Sample Input
2
5 7
1 2 3 4 5
6 7
1 2 3 4 5 6
Sample Output
4
6
Source
2017 Multi-University Training Contest - Team 7