IBMOA #49
Max XOR
Estimated EasyJudge-ready
Topics (AI-labelled)Bits & Math
Choose lo≤a<b≤hi such that a XOR b≤k and the XOR value is as large as possible; return the XOR value. The two integers must be different; if no feasible pair exists, this site outputs -1.
Input
One line containing lo hi k. Full source ranges: 1≤lo<hi≤10000, 1≤k≤10000.
Output
Output one integer, the answer.
Example 1
Input:
3 5 6
Output:
6
Example 2
Input:
1 2 1
Output:
-1
Example 3
Input:
1 4 7
Output:
7
Example notes
The examples give 6, -1 and 7 respectively.
Editorial
Loading solution…