Mocha and Math solution codeforces
Mocha is a young girl from high school. She has learned so much interesting knowledge from her teachers, especially her math teacher. Recently, Mocha is learning about binary system and very interested in bitwise operation.
This day, Mocha got a sequence bitwise AND operation. This operation can be performed any number of times.of length . In each operation, she can select an arbitrary interval and for all values ( ), replace with at the same time, where denotes the
For example, if, the array is , and Mocha selects the interval , then the new array is .
Now Mocha wants to minimize the maximum value in the sequence. As her best friend, can you help her to get the answer?
Each test contains multiple test cases.
The first line contains a single integer( ) — the number of test cases. Each test case consists of two lines.
The first line of each test case contains a single integer( ) — the length of the sequence.
The second line of each test case containsintegers ( ).
For each test case, print one integer — the minimal value of the maximum value in the sequence.
4 2 1 2 3 1 1 3 4 3 11 3 7 5 11 7 15 3 7
0 1 3 3
In the first test case, Mocha can choose the interval, then the sequence becomes , where the first element is , and the second element is .
In the second test case, Mocha can choose the interval, then the sequence becomes , where the first element is , the second element is , and the third element is .
Solution: Click here