#B3908. 异或构造题

异或构造题

题目描述

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

你需要计算 xxa1a2anxa_1\oplus a_2\oplus\cdots\oplus a_n\oplus x

其中 \oplus 代表异或,x ^ y 在 C++ 中可表示为 x ^ y

对于两个非负整数 x,yx,y,它们的异或是指,将它们作为二进制数,对二进制表示中的每一位进行如下运算得到的结果:

  • xxyy 的这一位上不同时,结果的这一位为 11
  • xxyy 的这一位上相同时,结果的这一位为 00

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

输入格式

输入共两行。

第一行一个整数 nn,代表序列 aa 的长度。

第二行 nn 个整数 a1,a2,,ana_1,a_2,\cdots,a_n,代表序列 aa

输出格式

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

样例 #1

样例输入 #1

2
1 2

样例输出 #1

3 0

样例 #2

样例输入 #2

2
7 7

样例输出 #2

0 0

提示

A=a1a2anA=a_1\oplus a_2\oplus\cdots\oplus a_n,则 $a_1\oplus a_2\oplus\cdots\oplus a_n\oplus x=A\oplus x$ 恒为非负整数,最小可能值为 00。取 x=Ax=A 即可达到 00

数据规模与约定

对于 100%100\% 的数据,1n1061 \leq n \leq 10^60ai10180 \leq a_i \leq 10^{18}