| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB | 328 | 122 | 106 | 40.152% |
We define the beauty of an array as the value of its minimum excluded value (MEX$^{\dagger}$). A larger MEX corresponds to a more beautiful array.
You are given an array $A$ of length $N$. You want to enhance it in terms of its beauty. To achieve this, you can choose a non-negative integer $x$ and replace each element $A_i$ with $A_i\wedge x$ where $\wedge$ denotes the bitwise AND operator.
Find the optimal value of $x$ that maximizes the beauty of the array.
The first line contains a single integer $T$ --- the number of test cases.
The first line of each test case contains a single integer $N$.
The second line of each test case contains $N$ space-separated integers $A_1,\ldots ,A_N$.
For each test case, print a single line containing a single integer $x$ that maximizes the MEX of the array formed by taking the bitwise AND of each element of $A$ with $x$. If there are multiple solutions, you may print any.
1 6 13 11 40 10 33 19
23
In the sample, we can choose $x=23,ドル so the new array will be \[[13\wedge 23,,円 11\wedge 23,,円 40\wedge 23,10\wedge 23,,円 33\wedge 23,,円 19\wedge 23] =[5,3,0,2,1,19]\] which has a MEX of 4ドル$. Another possible answer is $x=19$.
${}^{\dagger}$ The MEX of an array is the smallest non-negative integer that does not belong to the array. For instance, the MEX of $[2,2,1]$ is 0ドル,ドル the MEX of $[3,1,0,1]$ is 2ドル,ドル and the MEX of $[0,3,1,2]$ is 4ドル$.