A. Absolute Maximization
You are given an array of length . You can perform the following operation several (possibly, zero) times:
- Choose , , : Swap the -th digit in the binary representation of and .
Find the maximum possible value of .
In a binary representation, bits are numbered from right (least significant) to left (most significant). Consider that there are an infinite number of leading zero bits at the beginning of any binary representation.
For example, swap the -th bit for and will result and . Swap the -nd bit for and will result and .
Here, denotes the maximum element of array and denotes the minimum element of array .
The binary representation of is written in base . For example, and written in base are and , respectively.
The first line contains a single integer () — the number of testcases.
The first line of each test case contains a single integer () — the length of array .
The second line of each test case contains integers () — the elements of array .
It's guaranteed that the sum of over all testcases does not exceed .
For each testcase, print one integer — the maximum possible value of .
problem code in cpp make sure to change the variable-----------


No comments:
Post a Comment