T405866 异或构造题?

题目描述

给定 $n$ 个非负整数 $a _ 1, a _ 2, \cdots, a _ n$,你需要确定一个非负整数 $x$,使得 $a _ 1 \oplus a _ 2 \oplus \cdots \oplus a _ n \oplus x$ 最小。 你需要计算 $x$ 和 $a _ 1 \oplus a _ 2 \oplus \cdots \oplus a _ n \oplus x$。 其中 $\oplus$ 代表异或,$x \oplus y$ 在 C++ 中可表示为 `x ^ y`。 对于两个非负整数 $x,y$,它们的**异或**是指,将它们作为二进制数,对二进制表示中的每一位进行如下运算得到的结果: - $x$ 和 $y$ 的这一位上不同时,结果的这一位为 $1$; - $x$ 和 $y$ 的这一位上相同时,结果的这一位为 $0$。 例如:$0\oplus 0=0$,$1\oplus 0=1$,$0\oplus 1=1$,$1\oplus 1=0$。

输入格式

输入共两行。 第一行一个整数 $n$,代表序列 $a$ 的长度。 第二行 $n$ 个整数 $a _ 1, a _ 2, \cdots, a _ n$,代表序列 $a$。

输出格式

输出共一行两个整数 $x$ 和 $a _ 1 \oplus a _ 2 \oplus \cdots \oplus a _ n \oplus x$。

说明/提示

### 数据规模与约定 对于 $100\%$ 的数据,$1 \leq n \leq 10 ^ 6$,$0 \leq a _ i \leq 10 ^ {18}$。 | 测试点 | $n$ | $a _ i$ | 特殊性质 | | :-: | :-: | :-: | :-: | | $1$ | $= 1$ | $\leq 10 ^ 3$ | 无 | | $2$ | $= 2$ | $\leq 10 ^ 3$ | $a _ 1 = a _ 2$ | | $3 \sim 4$ | $= 2$ | $\leq 10 ^ 3$ | 无 | | $5$ | $\leq 10 ^ 3$ | $= 0$ | 无 | | $6 \sim 8$ | $\leq 10 ^ 3$ | $\leq 10 ^ 3$ | 无 | | $9 \sim 11$ | $\leq 10 ^ 6$ | $\leq 10 ^ 3$ | 无 | | $12 \sim 13$ | $\leq 10 ^ 6$ | $\leq 1$ | 无 | | $14 \sim 20$ | $\leq 10 ^ 6$ | $\leq 10 ^ {18}$ | 无 |