#include<bits/stdc++.h>
#define MAXN 2005
#define reg register
#define inl inline
using namespace std;
int n;
bool ans[MAXN][MAXN];
void Dfs(reg int x,reg int y,reg int xx,reg int yy)
{
if(x==xx && y==yy) return;
reg int tx=(x+xx)/2,ty=(y+yy)/2;
for(reg int i=x;i<=tx;i++)
{
for(reg int j=y;j<=ty;j++) ans[i][j]=1;
}
Dfs(x,ty+1,tx,yy);
Dfs(tx+1,y,xx,ty);
Dfs(tx+1,ty+1,xx,yy);
}
int main()
{
reg int x;
scanf("%d",&x);
n=1<<x;
Dfs(1,1,n,n);
for(reg int i=1;i<=n;i++)
{
for(reg int j=1;j<=n;j++) printf("%d%c",ans[i][j]?0:1,j==n?'\n':' ');
}
return 0;
}
dfs-战营
Guess you like
Origin blog.csdn.net/weixin_52045928/article/details/115981898
Recommended
Ranking