#nt203. 逆元2
逆元2
Modular Inverses 2
Problem Description
Given a prime , compute the modular inverses of modulo . Since the output could be large, you only need to output the XOR sum of these inverses.
Output one integer: the XOR sum of the inverses of . If , we take its inverse to be .
To avoid an excessively large input, the sequence is generated by the following code:
unsigned int A, B, C;
inline unsigned int rng61() {
A ^= A << 16;
A ^= A >> 5;
A ^= A << 1;
unsigned int t = A;
A = B;
B = C;
C ^= t ^ A;
return C;
}
int main() {
scanf("%d%d%u%u%u", &p, &n, &A, &B, &C);
for (int i = 1; i <= n; i++)
a[i] = rng61()%p;
}
Input Format
One line containing five integers .
Output Format
One integer: the XOR sum of the inverses of modulo .
Sample Input
10007 1000 1 2 3
Sample Output
3611
Constraints
For all test cases, , , and .