OR-XOR
Practice
3.8 (5 votes)
Basic programming
Problem
60% Success 2298 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given an array A of size N, you could choose some non-negative number X and change every element of the given array to Ai=Ai⊕X

Here, ⊕ denotes the bitwise XOR operation.

Print the number of total possible values of X for which bitwise OR of every element of the array would be minimum.

Input format

  • The first line contains T denoting the number of test cases.
  • The first line of each test case contains integers N, denoting the size of the array A.
  • The next line contains N integers.

Output format

Print the number of total possible values of X for which bitwise OR of every element of the array would be minimum.

Constraints

1≤T≤5000
1≤N≤105
0≤Ai≤109

The sum of N over all test cases does not exceed 2â‹…105

Sample Input
1
2
1 4
Sample Output
4
Explanation

Here minimum possible bitwise OR of the array is 5.

All possible values for 'X' are 0,1,4,5.

Code Editor

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Submissions
Please login to view your submissions
Similar Problems
Points:30
3 votes
Tags:
ApprovedMapsMediumSetsapprovedhiringrecruit
Points:30
17 votes
Tags:
ApprovedImplementationMediumOpenString Manipulation
Points:30
5 votes
Tags:
AlgorithmsApprovedMathMediumOpen
Editorial

Login to unlock the editorial