MEX-OR solution codechef
The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance:
- The MEX of is , because does not belong to the array.
- The MEX of is , because and belong to the array, but does not.
- The MEX of is 4 because and belong to the array, but does not.
Find the maximum possible MEX of an array of non-negative integers such that the bitwise OR of the elements in the array does not exceed .
Input Format MEX-OR solution codechef
- The first line contains denoting the number of test cases. Then the test cases follow.
- Each test case contains a single integer on a single line.
Output Format MEX-OR solution codechef
For each test case, output on a single line the maximum possible MEX of the array satisfying the given property.
Constraints MEX-OR solution codechef
Subtasks MEX-OR solution codechef
Subtask 1 (100 points): Original constraints
Sample Input 1 MEX-OR solution codechef
4 0 1 2 5
Sample Output 1 MEX-OR solution codechef
1 2 2 4
Explanation MEX-OR solution codechef
Test case: The array could be .
Test case: The array could be . Here the bitwise OR of and is and the MEX of the array is as both and belongs to the array.
Test case: The array could be . Here the bitwise OR of all integers in the array is and the MEX of the array is .