#P11485. 「Cfz Round 5」Non-breath Oblige
「Cfz Round 5」Non-breath Oblige
Description
Given three integers , where .
You can perform several operations. In each operation, you can choose a non-negative integer and modify the value of to , subject to the following conditions:
- It must satisfy ;
- It must satisfy , where denotes the bitwise OR operation;
- The cost you need to pay is , where denotes the bitwise XOR operation.
You need to find the minimum sum of costs required to make .
Input Format
Each test contains multiple test cases.
The first line of input contains a positive integer , denoting the number of test cases.
Each test case is given in a following line, containing three integers .
Output Format
For each test case, output a single integer on a line, representing the minimum sum of costs required to make .
3
2 1 2
3 1 1
5 1 4
3
0
57
Hint
Sample Explanation #1
For the first test case, since , you can directly change the value of from to , with a cost of , which is . It can be proven that the minimum sum of costs required to make is .
For the second test case, no operation is needed to satisfy .
Constraints
For all test cases, it is guaranteed that:
- ;
- ;
- .
Subtasks are used in this task.
- Subtask 0 (12 points): .
- Subtask 1 (15 points): .
- Subtask 2 (20 points): .
- Subtask 3 (10 points): .
- Subtask 4 (18 points): .
- Subtask 5 (25 points): No further restrictions.
京公网安备 11011102002149号