为什么不会超时?
  • 板块P5461 赦免战俘
  • 楼主yhyds
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/1/17 12:27
  • 上次更新2023/10/24 03:52:37
查看原帖
为什么不会超时?
578667
yhyds楼主2023/1/17 12:27
#include<bits/stdc++.h>
using namespace std;
int a[1050][1050];
int main(){
	int n,e=1;
	cin>>n;
	for(int i=1;i<=n;i++)e*=2;
	a[1][1]=1;
	for(int i=2;i<=e;i++){
		for(int j=1;j<=i;j++){
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%2;
		}
	}
	for(int i=1;i<=e;i++){
		for(int j=e;j>=1;j--){
			cout<<a[i][j]<<' ';
		}
		cout<<endl;
	}
}

我输入了9,结果好久都没算完,提交居然AC了,这是怎么回事呢?

2023/1/17 12:27
加载中...