309554: CF1698A. XOR Mixup

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

XOR Mixup

题意翻译

给你 $n$ 个数,有 $n-1$ 个是 $a_1\sim a_{n-1}$,还有一个是 $x$,等于 $a_1\oplus a_2\oplus\cdots\oplus a_{n-1}$($\oplus$ 代表异或运算)。请你输出 $x$,如有多个答案,输出任意一个。多组数据。 Translated by [庄nnnn额](https://www.luogu.com.cn/user/521592)

题目描述

There is an array $ a $ with $ n-1 $ integers. Let $ x $ be the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all elements of the array. The number $ x $ is added to the end of the array $ a $ (now it has length $ n $ ), and then the elements are shuffled. You are given the newly formed array $ a $ . What is $ x $ ? If there are multiple possible values of $ x $ , you can output any of them.

输入输出格式

输入格式


The input consists of multiple test cases. The first line contains an integer $ t $ ( $ 1 \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 $ n $ ( $ 2 \leq n \leq 100 $ ) — the number of integers in the resulting array $ a $ . The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 0 \le a_i \le 127 $ ) — the elements of the newly formed array $ a $ . Additional constraint on the input: the array $ a $ is made by the process described in the statement; that is, some value of $ x $ exists.

输出格式


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

输入输出样例

输入样例 #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 $ a $ is $ a=[2, 5, 4] $ . Then $ x = 2 \oplus 5 \oplus 4 = 3 $ ( $ \oplus $ denotes the bitwise XOR), so the new array is $ [2, 5, 4, 3] $ . Afterwards, the array is shuffled to form $ [4, 3, 2, 5] $ . In the second test case, one possible array $ a $ is $ a=[1, 10, 6, 10] $ . Then $ x = 1 \oplus 10 \oplus 6 \oplus 10 = 7 $ , so the new array is $ [1, 10, 6, 10, 7] $ . Afterwards, the array is shuffled to form $ [6, 1, 10, 7, 10] $ . In the third test case, all elements of the array are equal to $ 6 $ , so $ x=6 $ . In the fourth test case, one possible array $ a $ is $ a=[100, 100] $ . Then $ x = 100 \oplus 100 = 0 $ , so the new array is $ [100, 100, 0] $ . Afterwards, the array is shuffled to form $ [100, 100, 0] $ . (Note that after the shuffle, the array can remain the same.)

Input

题意翻译

给你 $n$ 个数,有 $n-1$ 个是 $a_1\sim a_{n-1}$,还有一个是 $x$,等于 $a_1\oplus a_2\oplus\cdots\oplus a_{n-1}$($\oplus$ 代表异或运算)。请你输出 $x$,如有多个答案,输出任意一个。多组数据。 Translated by [庄nnnn额](https://www.luogu.com.cn/user/521592)

Output

**题目大意:**
题目给出了一个数组,这个数组包含n个整数,其中n-1个整数为a_1到a_{n-1},还有一个整数x,x等于数组中所有其他整数的异或运算结果。你需要输出x的值。如果有多个可能的x值,输出其中任意一个。题目包含多组数据。

**输入输出数据格式:**
- **输入格式:**
- 第一行包含一个整数t(1≤t≤1000),表示测试用例的数量。
- 每个测试用例包含两行:
- 第一行包含一个整数n(2≤n≤100),表示数组a的长度。
- 第二行包含n个整数a_1, a_2, ..., a_n(0≤a_i≤127),表示新形成的数组a的元素。
- **输出格式:**
- 对于每个测试用例,输出一个整数x,即题目描述中的值。如果有多个可能的x值,输出其中任意一个。

**输入输出样例:**
- 输入样例 #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
```**题目大意:** 题目给出了一个数组,这个数组包含n个整数,其中n-1个整数为a_1到a_{n-1},还有一个整数x,x等于数组中所有其他整数的异或运算结果。你需要输出x的值。如果有多个可能的x值,输出其中任意一个。题目包含多组数据。 **输入输出数据格式:** - **输入格式:** - 第一行包含一个整数t(1≤t≤1000),表示测试用例的数量。 - 每个测试用例包含两行: - 第一行包含一个整数n(2≤n≤100),表示数组a的长度。 - 第二行包含n个整数a_1, a_2, ..., a_n(0≤a_i≤127),表示新形成的数组a的元素。 - **输出格式:** - 对于每个测试用例,输出一个整数x,即题目描述中的值。如果有多个可能的x值,输出其中任意一个。 **输入输出样例:** - 输入样例 #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 ```

加入题单

算法标签: