#P13552. 鱼类考古学
鱼类考古学
Description
You accidentally obtained non-negative integers, where the -th number is .
Since there are too many numbers to store at home, you decide to merge them into a single number.
You can perform two types of operations:
- Choose two numbers and , then merge them into a new number .
- Choose two numbers and , then merge them into a new number .
Here, denotes the bitwise AND operation. The two numbers chosen do not need to be adjacent.
Due to certain constraints, you must use Operation 1 exactly times in the steps of merging. Your task is to maximize the final remaining number.
To help you understand the problem, here’s an example for , , and :
- Use Operation 2 to merge and into . Now becomes .
- Use Operation 1 to merge and into . Now becomes .
Input Format
Each test case contains sets of inputs.
For each test case:
- The first line contains two integers, and .
- The second line contains integers, where the -th integer is .
Output Format
Output a single integer representing the answer.
3
3 2
1 2 3
4 3
2 5 6 4
5 1
1 3 7 9 11
3
12
1
Hint
- For Sample 1, the explanation is provided in the problem description.
- For Sample 2, merge and using Operation 1, then use Operation 2 for the remaining merges. It can be proven that no solution yields a result greater than .
- For Sample 3, the only possible answer is merging all numbers using Operation 1.
Data Range
| Sub | Points | Special Constraints | ||
|---|---|---|---|---|
| None | ||||
| None | ||||
Here, denotes the number of s in the binary representation of .
For all test cases:
- ,
- ,
- ,
- The sum of across all test cases does not exceed .
Special Note: For Subtask 1, .
Generated by Deepseek V3.
京公网安备 11011102002149号