| VI UnBalloon Contest Mirror |
|---|
| Finished |
Lórien, the last of the wizards of the Kingdom of Lagrange, found a secret formula carved into the walls of an ancient tower. It represents the absolute value of a powerful polynomial that, according to legends, possesses magical properties when applied correctly. The formula is:
$$$$$$f(x) = |(A+C)x^3 - Bx^2 + BCx + (x+C)(x-A)|.$$$$$$
To protect this knowledge, Lórien needs to apply the function to several values and reveal only the final result of a disguise spell: the XOR ($$$\oplus$$$) of all the results of the evaluations $$$f(x)$$$ at these values.
The XOR between two numbers $$$a$$$ and $$$b$$$ is another number $$$c$$$. To calculate $$$a \oplus b = c$$$, write the binary representation of $$$a$$$ and $$$b$$$. Each bit (digit in binary representation) of $$$c$$$ will be $$$1$$$ if the corresponding bits in $$$a$$$ and $$$b$$$ are different, and $$$0$$$ otherwise.
Your mission is to help him calculate this final value.
The first line contains three integers $$$A, B$$$ and $$$C (-100 \leq A, B, C \leq 100)$$$.
The second line contains an integer $$$Q (2 \leq Q \leq 1000)$$$, the number of values.
The third line contains $$$Q$$$ integers $$$X_1, X_2, \dots, X_Q (-100 \leq X_i \leq 100)$$$, the values for which the function $$$f$$$ should be evaluated.
Print a single integer: the XOR of all values $$$f(X_i)$$$, for $$$1 \leq i \leq Q$$$.
1 2 330 1 2
34
13 100 -1741 -10 5 -5
7509
In the first test case, we have $$$f(0) = |-3| = 3$$$, $$$f(1) = |8| = 8$$$, and $$$f(2) = |41| = 41$$$. The binary representations of $$$f(0), f(1)$$$, and $$$f(2)$$$, respectively, are as follows: $$$$$$000011$$$$$$ $$$$$$001000$$$$$$ $$$$$$101001$$$$$$. Thus, the XOR of these values in binary is $$$100010$$$, which is $$$34$$$ in decimal.
| Name |
|---|


