#L0215. 最优异或值

最优异或值

题目描述

给定 nn 个非负整数 a1,a2,,ana_1, a_2, \cdots, a_n,你需要确定一个非负整数 xx,使得 a1a2anxa_1 \oplus a_2 \oplus \cdots \oplus a_n \oplus x 的值最小。

你需要输出这个 xx 以及对应的最小值。

其中 \oplus 代表按位异或运算,即 C++ 中的 ^ 运算符。对于两个非负整数的每一位:

  • 两位不同时结果为 11
  • 两位相同时结果为 00

例如:00=00 \oplus 0 = 010=11 \oplus 0 = 101=10 \oplus 1 = 111=01 \oplus 1 = 0

输入格式

输入共两行。

第一行一个整数 nn,表示序列长度。
第二行 nn 个整数 a1,a2,,ana_1, a_2, \cdots, a_n

输出格式

输出一行两个整数:xxa1a2anxa_1 \oplus a_2 \oplus \cdots \oplus a_n \oplus x

样例

2
1 2
3 0
2
7 7
0 0

提示

数据规模与约定

对于 100%100\% 的数据,1n1061 \leq n \leq 10 ^ 60ai10180 \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}$
难度 入门
通过率
尝试 0
已通过 0
ID
943
类型
传统题
Time Limit
1000ms
Memory Limit
512MiB
上传者