CF1805A.We Need the Zero
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is an array a consisting of non-negative integers. You can choose an integer x and denote bi=ai⊕x for all 1≤i≤n , where ⊕ denotes the bitwise XOR operation. Is it possible to choose such a number x that the value of the expression b1⊕b2⊕…⊕bn equals 0 ?
It can be shown that if a valid number x exists, then there also exists x such that ( 0≤x<28 ).
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤1000 ). The description of the test cases follows.
The first line of the test case contains one integer n ( 1≤n≤103 ) — the length of the array a .
The second line of the test case contains n integers — array a ( 0≤ai<28 ).
It is guaranteed that the sum of n over all test cases does not exceed 103 .
输出格式
For each set test case, print the integer x ( 0≤x<28 ) if it exists, or −1 otherwise.
输入输出样例
输入#1
5 3 1 2 5 3 1 2 3 4 0 1 2 3 4 1 2 2 3 1 1
输出#1
6 0 3 -1 1
说明/提示
In the first test case, after applying the operation with the number 6 the array b becomes [7,4,3] , 7⊕4⊕3=0 .
There are other answers in the third test case, such as the number 0 .