For a permutation of integers from to , let's define its value as .
Given , find the maximum possible value of the permutation of integers from to .
As a reminder, denotes the bitwise XOR operation
Input Format
The first line of the input contains a single integer the number of test cases. The description of test cases follows.
The only line of each test case contains a single integer .
Output Format
For each test case, output the maximum possible value of the permutation of integers from to .
Constraints
- .
Subtasks
Subtask 1 (60 points): The sum of over all test cases doesn't exceed . Subtask 2 (40 points): No additional constraints.
Sample Input 1
5
1
2
3
4
29012022
Sample Output 1
0
6
6
20
841697449540506
Explanation
For , the only such permutation is , its value is .
For , the permutation with the best value is , with value .
For , the permutation with the best value is , with value .
For , the permutation with the best value is , with value .
Solution:
This question solution is updated within contest time. please click on follow button and subscribe our channel.if you follow and subscribe our channel then get notification of answer as soon as possible.
No comments:
Post a Comment