Picking Out Numbers
Time limit2sMemory limit512 MB
Choose between 1 and k distinct integers from [l, r] minimizing the XOR of the chosen set, and output that minimum XOR.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Math, Greedy, Dynamic programming
- Solved
- No attempts yet
Problem
Seonggwan wants to build a set that satisfies all of the following conditions.
- Every element of is a natural number, and no two elements are equal.
- Every element of is at least and at most .
- The number of elements of is at least and at most .
Choose so that the bitwise XOR of all its elements is as small as possible, and find that XOR value.
Input
The first line contains the natural numbers , , , separated by spaces. (, )
Output
Print the smallest XOR value on the first line. Several sets can reach that smallest value, but the output is that single value.