Problem D
XORsistinn
Languages
en
is
Gunnar the priest received a mysterious message by post yesterday that said that one of his parishioners might be possessed. On the back it said ,,You are our only hope XORsist!". Gunnar was in fact a sorcerer and had great experience in repelling spirits and demons.
He decided to write down the names of everyone at his sermon and ended up with names numbered from $1$ to $N$. Later he realized that he took the XOR of all the numbers from $1$ to $N$ that would give him information on who’s possessed; if the number is $0$ no one is possessed and if it’s between $1$ and $N$ then it would be the person on the list corresponding to that number. If it’s larger than $N$ it must be Gunnar himself that’s possessed and then we’re all in trouble!
Explanation of XOR
XOR, usually denoted by $~ \hat{}~ $ in programming languages, is an operation that takes two numbers and returns a new number. The operation is performed on the two numbers in binary , bit by bit. The following table shows how a new bit is calculated from the corresponding bits in the input numbers.
A |
B |
A XOR B |
1 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
0 |
Let us take an example. The number $1337$ in binary is 10100111001 and the number $1993$ in binary is 11111001001.
1337 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
1 |
1993 |
1 |
1 |
1 |
1 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
1337 XOR 1993 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
The result is 01011110000 which is the number $752$.
Input
The first and only line of the input contains an integer $N$, how many parishioners are at Gunnar’s sermon.
Output
Print the number of the parishioner that’s possessed, Enginn if the value is $0$ and Gunnar if the value is greater than $N$.
Explanation of Sample Inputs
In the first sample $N = 3$. If we calculate the XOR of all values from $1$ to $N$ we get $(1\textrm{ XOR }2)\textrm{ XOR }3 = 0$. Thus no one is possessed so the answer is Enginn.
In the second input $N = 6$. If we calculate the XOR of all numbers from $1$ to $N$ the result is $7$. Gunnar is thus possessed and the answer is Gunnar.
In the third sample $N = 5$. If we calculate the XOR of all numbers from $1$ to $N$ the result is $1$. Thus the first person on the list is possessed, so the answer is 1.
Scoring
The solution will be tested on input data of varying difficulty and the data is divided into groups as shown in the table below. The solution will then be scored according to how many groups are solved.
Group |
Points |
Constraints |
1 |
50 |
$ 1 \le N \le 1000$ |
2 |
50 |
$ 1 \le N \le 10^{18}$ |
Sample Input 1 | Sample Output 1 |
---|---|
3 |
Enginn |
Sample Input 2 | Sample Output 2 |
---|---|
6 |
Gunnar |
Sample Input 3 | Sample Output 3 |
---|---|
5 |
1 |