No.1674 Introduction to XOR
タグ : / 解いたユーザー数 254
作問者 :
stoq
/ テスター :
akakimidori
wait_sushi
Problem Statement
You are given a sequence $\{A_i\}$ of length $N$.
Find the minimum positive integer $X$ that satisfies the following condition. It can be shown that, under the given constraints, an $X$ satisfying the condition always exists.
- For every $1 \leq i \leq N$, $X + A_i = X \oplus A_i$
Here, $\oplus$ denotes bitwise XOR.
Input
$N$ $A_1 \dots A_N$
- All inputs are integers.
- $1 \leq N \leq 100$
- $1 \leq A_i \leq 10^{18}$
Output
Output the minimum positive integer $X$ that satisfies the condition.
Sample
Sample 1
Input
3 1 2 9
Output
4
Since $4 + 1 = 4 \oplus 1 = 5, \ 4+2 = 4 \oplus 2 = 6,\ 4+9=4 \oplus 9 = 13$, $4$ satisfies the condition.
There is no smaller $X$, so output $4$.
Sample 2
Input
5 1 3 5 7 9
Output
16
Sample 3
Input
1 576460752303423487
Output
576460752303423488
The output may not fit in a 32-bit integer.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。