#P7526. Virtual Self
Virtual Self
Description
Technic_Angel wants to use particles to create a beautiful crystal. Pathselector tells her that a crystal is made by combining clusters of particles. Each cluster has a beauty value (a non-negative integer less than , where is a given positive integer), and the beauty value of a crystal is the XOR sum of the beauty values of all particles used to make it.
Technic_Angel has many particles: for each , she has exactly clusters of particles whose beauty value is . Now Technic_Angel wants to know how many ways there are to make a crystal with beauty value . (Two ways are different if and only if there exists a cluster of particles that is used in one way but not in the other; all particles are distinct.) Unfortunately, she cannot solve this problem, so she comes to you, who are good at OI.
After you finish this problem in , the pleasantly surprised Technic_Angel wants you to solve the above problem for all . However, since the answer is too large, she only asks you to tell her the XOR sum of for all , where is the number of ways to make a crystal with beauty value . That is,
$$(f(0)\bmod P)\otimes(2f(1)\bmod P)\otimes\cdots\otimes(2^wf(2^w-1)\bmod P)$$where , and denotes XOR. Note that this is the XOR of the values after taking modulo, not taking modulo after XOR.
Input Format
The first line contains two positive integers , representing the number of particle clusters needed to form a crystal and the parameter in the problem.
The second line contains positive integers; the -th integer represents .
Output Format
Output one integer in one line, representing the XOR sum of .
2 2
0 1 1 1
5
3 3
2 0 1 7 1 2 0 1
320
5 3
2 0 2 1 0 4 2 3
1482
Hint
Sample Explanation
Sample 1: Technic_Angel has three clusters of particles, with beauty values . If we represent the beauty values of the selected particles as a sequence, then there is no way to form a crystal with beauty value , and there is exactly one way each for beauty value , , and (they are , , and , respectively). Therefore the answer is .
Constraints
Let . For all testdata, , , .
| Subtask | Special Properties | Score | |
|---|---|---|---|
| 1 | 5 | ||
| 2 | 10 | ||
| 3 | 20 | ||
| 4 | None | 25 | |
| 5 | 38 | ||
| 6 | None | 2 |
Special property : .
Special property : .
Translated by ChatGPT 5
京公网安备 11011102002149号