You are given an integer 'X' and your task is to find an integer 'Y' such that the bitwise XOR of the integers 'X' and 'Y' give the maximum possible value. The integer 'Y' should not be greater than 2305843009213693951 ((2^61) - 1).
A bitwise XOR is a binary operation that takes two bit patterns of equal length and performs the logical exclusive OR operation on each pair of corresponding bits. The result in each position is 1 if only one of the bits is 1, but will be 0 if both are 0 or both are 1.
Note:
1. The maximum obtainable value can always be stored in 64-bit memory space.
2. The given number 'X' is always non-negative.
The first line of the input contains an integer 'T' denoting the number of test cases.
The first line and the only line of each test case contains an integer 'X'.
Output Format:
For each test case, print an integer 'Y' whose XOR with 'X' yields the maximum obtainable value in separate line.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10^4
0 <= X <= 10^18
Time Limit: 1sec
1
16
2305843009213693935
The XOR of numbers 16 and 2305843009213693935 equals 2305843009213693951, which is the maximum allowed XOR value.
1
0
2305843009213693951
You can observe that the bitwise xor of same bits is 0, while different bits is 1.
O(1), as all operations take constant time.
O(1), as we are using constant extra memory.