求助大佬,好多re
查看原帖
求助大佬,好多re
427110
Logiking楼主2020/12/6 18:07

第一个测试点过了,剩下都是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;
} 
2020/12/6 18:07
加载中...