@[wuzeyong](/user/840470)
```cpp
for(i=1;i<=n;i++)
for(int j=i;j<n;j+=i)
a[j]=not a[j];
```
#### 改成:
```cpp
for(i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[j]=not a[j];
```
就可以了
by mysterys @ 2022-12-04 17:43:04
@[wuzeyong](/user/840470) 你少写了一个等于号
by mysterys @ 2022-12-04 17:43:35
@[wuzeyong](/user/840470) 另外您的输出我也帮您优化了:
#### 优化后的代码:
```cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
bool a[5001];
memset(a,true,sizeof(a));
cin>>n;
for(i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[j]=!a[j];
for(i=1;i<=n;i++)
{
if(a[i]==0)
{
cout<<i<<" ";
}
}
return 0;
}
```
已经AC了:[AC](https://www.luogu.com.cn/record/96556428)
by mysterys @ 2022-12-04 17:47:38
@[mysterys](/user/659165)
非常感谢!!!
by wuzeyong @ 2022-12-04 18:56:52
@[wuzeyong](/user/840470) 给个关注谢谢
by mysterys @ 2022-12-04 20:27:00
@[mysterys](/user/659165) 谢谢
by SNXL @ 2023-03-24 20:56:11