CF1698A.XOR Mixup

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is an array aa with n−1n-1 integers. Let xx be the bitwise XOR of all elements of the array. The number xx is added to the end of the array aa (now it has length nn), and then the elements are shuffled.

You are given the newly formed array aa. What is xx? If there are multiple possible values of xx, you can output any of them.

有一个包含 n−1n-1 个整数的数组 aa。令 xx 为该数组所有元素的按位异或。将数 xx 添加到数组 aa 的末尾(此时其长度变为 nn),然后对元素进行随机打乱。

你被给定了这个新形成的数组 aa。请问 xx 是多少?如果存在多个可能的 xx 值,你可以输出其中任意一个。

输入格式

The input consists of multiple test cases. The first line contains an integer tt (1≤t≤10001 \leq t \leq 1000) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer nn (2≤n≤1002 \leq n \leq 100) — the number of integers in the resulting array aa.

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤1270 \le a_i \le 127) — the elements of the newly formed array aa.

Additional constraint on the input: the array aa is made by the process described in the statement; that is, some value of xx exists.

输入包含多个测试用例。第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(2≤n≤1002 \leq n \leq 100),表示最终数组 aa 中的整数个数。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤1270 \le a_i \le 127),即新构造的数组 aa 的元素。

输入的附加约束:数组 aa 是通过题目陈述中所描述的过程生成的;即,存在某个值 xx。

输出格式

For each test case, output a single integer — the value of xx, as described in the statement. If there are multiple possible values of xx, output any of them.

对于每个测试用例,输出一个整数 —— 即题目描述中所述的 xx 的值。如果存在多个可能的 xx 值,输出其中任意一个即可。

输入输出样例

  • 输入#1

    4
    4
    4 3 2 5
    5
    6 1 10 7 10
    6
    6 6 6 6 6 6
    3
    100 100 0

    输出#1

    3
    7
    6
    0

说明/提示

In the first test case, one possible array aa is a=[2,5,4]a=[2, 5, 4]. Then x=2⊕5⊕4=3x = 2 \oplus 5 \oplus 4 = 3 (⊕\oplus denotes the bitwise XOR), so the new array is [2,5,4,3][2, 5, 4, 3]. Afterwards, the array is shuffled to form [4,3,2,5][4, 3, 2, 5].

In the second test case, one possible array aa is a=[1,10,6,10]a=[1, 10, 6, 10]. Then x=1⊕10⊕6⊕10=7x = 1 \oplus 10 \oplus 6 \oplus 10 = 7, so the new array is [1,10,6,10,7][1, 10, 6, 10, 7]. Afterwards, the array is shuffled to form [6,1,10,7,10][6, 1, 10, 7, 10].

In the third test case, all elements of the array are equal to 66, so x=6x=6.

In the fourth test case, one possible array aa is a=[100,100]a=[100, 100]. Then x=100⊕100=0x = 100 \oplus 100 = 0, so the new array is [100,100,0][100, 100, 0]. Afterwards, the array is shuffled to form [100,100,0][100, 100, 0]. (Note that after the shuffle, the array can remain the same.)

在第一个测试用例中,一个可能的数组 aa 是 a=[2,5,4]a=[2, 5, 4]。此时 x=2⊕5⊕4=3x = 2 \oplus 5 \oplus 4 = 3(其中 ⊕\oplus 表示按位异或运算),因此新数组为 [2,5,4,3][2, 5, 4, 3]。随后,该数组被随机打乱,形成 [4,3,2,5][4, 3, 2, 5]。

在第二个测试用例中,一个可能的数组 aa 是 a=[1,10,6,10]a=[1, 10, 6, 10]。此时 x=1⊕10⊕6⊕10=7x = 1 \oplus 10 \oplus 6 \oplus 10 = 7,因此新数组为 [1,10,6,10,7][1, 10, 6, 10, 7]。随后,该数组被随机打乱,形成 [6,1,10,7,10][6, 1, 10, 7, 10]。

在第三个测试用例中,数组的所有元素均等于 66,因此 x=6x=6。

在第四个测试用例中,一个可能的数组 aa 是 a=[100,100]a=[100, 100]。此时 x=100⊕100=0x = 100 \oplus 100 = 0,因此新数组为 [100,100,0][100, 100, 0]。随后,该数组被随机打乱,形成 [100,100,0][100, 100, 0]。(注意:打乱后数组可能保持不变。)

输入解题思路,AI测评打分。不知道怎么写?

首页