Gug was learning about the XOR operator today, and has decided to define his own operation, the xorb operation, which stands for XORing in base B!
The procedure for XORing in base B is defined as follows:
Refer to the samples for more details.
Given three integers, X, Y and B, your task is to implement this xorb operation and find the answer.
Subtask 1 (33%): 1 ≤ X, Y ≤ 109, B = 2.
Subtask 2 (67%): 1 ≤ X, Y, B ≤ 109.
Subtask 3 (0%): Sample Testcases.
The only line of input will contain three integers, X, Y and B.
The only line of output should contain one integer, the answer of the xorb operation.
5 3 2
6
When converted to base 2, X = "101" and Y = "011". Therefore, by comparing each digit:
Therefore the final answer is "110", which converts back to 6.
170 131 5
276
Subtask | Score |
---|---|
1 | 33 |
2 | 67 |
3 | 0 |