本地成功编译输出正确,提交编译失败?

P1045 [NOIP2003 普及组] 麦森数

数组开大了
by InversionShadow @ 2023-07-08 10:17:33


开1e6可以的,[但是](https://www.luogu.com.cn/record/114398029)会有5个点TLE,自己改改 改后代码: ```cpp #include <bits/stdc++.h> using namespace std; const int MAXN=1e6; int p,len=1; short a[MAXN]={0,1}; int main() { cin>>p; for(int i=1;i<=p;i++) { int yu=0; for(int j=1;j<=len;j++) { a[j]*=2; a[j]+=yu; yu=a[j]/10; a[j]%=10; } if(yu) { a[++len]=yu; } } cout<<len<<'\n'; a[1]-=1; for(int i=500;i>=1;i--) { if(i<500&&i%50==0) cout<<'\n'; if(i>len) cout<<0; else cout<<a[i]; } return 0; } ```
by lym12 @ 2023-07-08 10:22:52


@[Mayile1022](/user/782768) OK我会了,感谢大佬!
by IOI_AK_TLR @ 2023-07-16 06:29:45


|