-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmagray1.cpp
More file actions
41 lines (39 loc) · 720 Bytes
/
magray1.cpp
File metadata and controls
41 lines (39 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// created by:DungTD
//
#include <bits/stdc++.h>
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define base int (1e9+7)
#define ll long long
using namespace std;
void solve(){
int n; cin >> n;
long k=pow(2,n);
string s[k+5];
s[1]='0';
s[2]='1';
int t=2;
if (n>1) {
int l;
for (int i=2; i<=n; i++) {
l=t*2;
for (int j=1; j<=t; j++) {
s[l-j+1]= "1" +s[j];
s[j]="0" + s[j];
}
t=l;
}
}
for (int i=1; i<=k; i++) cout << s[i] << " ";
cout << endl;
}
int main(){
faster();
int t;
cin >> t;
cin.ignore();
while (t--)
solve();
return 0;
}