#P1647. 锁
锁
Description
Given and , you are to generate a sequence from to . The first term of the sequence is , and the sequence must satisfy the following three conditions:
- The sequence has length , and every number from to is used exactly once.
- Any two adjacent numbers in the sequence are obtained by changing some bits of the previous number in its binary representation, where all the changed bits originally have the same value. That is, either change some s to s, or change some s to s, but not both at the same time.
- When multiple sequences satisfy the first two conditions, the sequence must be lexicographically smallest. In other words, when generating the next number from the previous one, always choose the smallest possible value (of course, still satisfying the first two conditions).
You are asked to find the maximum value among the first terms of this sequence. Output it in binary, with exactly bits, including leading zeros.
Input Format
A single line with two integers .
Output Format
A binary number representing the answer.
3 8
111
Hint
Sample Explanation
The generated sequence is . The maximum among the first terms is .
Constraints
For all testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号