MEX vs OR
Time limit2sMemory limit1024 MB
Given l, r, and x, the task is to compute the mex of the values (i OR x) for every i from l to r inclusive.
- Level
Easy2 of 10
- Topics
- Brute force, Bit manipulation
- Solved
- No attempts yet
Problem
A sequence of non-negative integers is given. The function is the smallest non-negative integer that is not contained in .
Examples of applying mex to a sequence:
For non-negative integers and , the bitwise OR is defined by these rules:
- If at least one of and has a 1 in the -th bit (in binary), then has a 1 in the -th bit.
- If both and have a 0 in the -th bit (in binary), then has a 0 in the -th bit.
Examples of computing the bitwise OR of two integers:
Non-negative integers , , and are given, with . You must find the value of the following expression.
Input
Three integers , , and are given on one line, separated by spaces. (, )
Output
Print the answer to the problem on one line.
Hint
In most languages, the bitwise OR of non-negative integers and can be computed with the operator |, as in (x|y).