Bitcoin Is God and I Am Invincible
Time limit1sMemory limit1024 MB
Choose exactly M values from N given numbers, repetition allowed, to maximize the bitwise XOR of the chosen values.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Bit manipulation, Brute force
- Solved
- No attempts yet
Problem
Chanho, who has four years of experience with coins and knows charts inside out, came up with the following formula that predicts the absolute value of the next monthly candle from the previous monthly candles.
(Absolute value of the next monthly candle) = the maximum over all choices of of the previous monthly candles, repetition allowed, of the bitwise xor of their absolute values
Given , , and the previous monthly candles , find the absolute value of the next monthly candle.
Input
The first line gives and .
The second line gives .
Output
Print the absolute value of the next monthly candle.