Problem7493--[CSES Problem Set] Gray Code

7493: [CSES Problem Set] Gray Code

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

A Gray code is a list of all $2^n$ bit strings of length $n$, where any two successive strings differ in exactly one bit (i.e., their Hamming distance is one).
Your task is to create a Gray code for a given length $n$.

Input

The only input line has an integer $n$.

Output

Print $2^n$ lines that describe the Gray code. You can print any valid solution.

Constraints

$1 \leq n \leq 16$

Sample 1 Input

2

Sample 1 Output

00
01
11
10

HINT

相同问题:CSES 2205

EDITORIAL

Source/Category