Xor Sum
Time limit2sMemory limit1024 MB
Find the minimum possible maximum of N nonnegative integers whose sum is S and whose XOR is X, or report -1 if no such sequence exists.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Binary search, Math
- Solved
- No attempts yet
문제
Determine whether there exists a sequence of nonnegative integers that satisfies both of the following conditions. If it exists, find the minimum possible value of the maximum element of the sequence.
- ( is the bitwise xor operation)
The input file contains tests.
입력
Input is given from standard input in the following format:
Here, , , and are the values of , , and for the -th test.
출력
Print lines. On the -th line, print if no sequence satisfies the conditions in the -th test. Otherwise, print the minimum possible value of the maximum element.
제한
- All values in the input are integers.
힌트
The following is a solution for each test:
- (3,3,3)
- (2,2,2,2)
- (2,3,3,3,4,4)
- (15)
- Impossible
- Impossible