#P2328. [SCOI2005] 超级格雷码
[SCOI2005] 超级格雷码
Problem Description
The well-known Gray code refers to a permutation of distinct -bit binary numbers (i.e., , with leading zeros added if necessary to ensure bits). This permutation satisfies the condition that any two adjacent binary numbers differ by at most one bit (e.g., and differ by one bit, while and differ by two bits, which does not meet the requirement). For instance, when , the sequence (, , , ) is a valid Gray code. The so-called super Gray code refers to the arrangement of distinct -digit -ary numbers that satisfies the above conditions. Given and , find a Gray code that meets the conditions. For numbers greater than , use to represent them ().
Input Format
Only one line, containing two integers and .
Output Format
A total of lines, each line is a base- number, representing the ordering that meets the required conditions.
2 2
00
01
11
10
Hint
。
Thanks to @Night_Aurora for the SPJ.
Translated by ChatGPT 5