我这代码为什么会MLE啊?求大神指点

P1876 开灯

@[Watchman](/space/show?uid=177228) 希望更丰富的展现?[使用Markdown](https://www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9%EF%BC%9Amarkdown)
by Smile_Cindy @ 2019-03-17 00:32:47


@[Watchman](/space/show?uid=177228) $2^{40}$ 的数组显然会 MLE 。 请尝试别的写法
by memset0 @ 2019-03-17 00:54:36


@[Watchman](/space/show?uid=177228) 这是数学题…… 小奥学过吗
by _Felix @ 2019-03-17 07:36:41


这太暴力了
by _Felix @ 2019-03-17 07:37:31


```cpp #include<iostream> #include<string.h> using namespace std; int main() { int N; cin>>N; int a[N+1]; memset(a,0,sizeof(int)*(N+1)); for(int i=1; i<=N; i++) { for(int j=0; j<=N; j+=i) { if(a[j]==0) a[j]=1; else a[j]=0; } } for(int i=1; i<=N; i++) { if(a[i]==1) { cout<<i<<' '; } } } ```
by chzhc @ 2019-03-17 08:49:57


希望更丰富的展现?使用Markdown
by wwwchen @ 2019-04-17 20:55:05


# 2^20 ......
by zhazha_855384 @ 2019-04-30 21:25:18


@[渣渣呵呵](/space/show?uid=133915) 错了,是2^40
by zhazha_855384 @ 2019-04-30 21:26:08


|