第一个测试点过了,剩下都是re,自己电脑运行不了,但是看题解和我思路一样
代码如下
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
int a[1250][1250];
void hanshu(int x,int y,int z){
if(z==2){
a[x][y] = 0;
return;
}
z = z/2;
int p,q;
for(p = x;p<p+z;p++)
for(q = y;q<p+z;q++)
a[p][q] = 0;
hanshu(x+z,y,z);
hanshu(x+z,y+z,z);
hanshu(x,y+z,z);
}
using namespace std;
int main(){
int n;
cin >> n;
int m = pow(2,n);
int i,j;
for(i = 1;i <= m;i++)
for(j = 1;j <= m;j++)
a[i][j]=1;
hanshu(1,1,m);
for(i = 1;i <= m;i++){
for(j = 1;j <= m-1;j++)
{
cout << a[i][j] << " " ;
}
cout << a[i][m] << endl;
}
return 0;
}