@[AFoxOfZzr](/space/show?uid=118086) 你的评测记录可以给我看一下吗?
by Eason_AC @ 2019-02-14 10:57:58
是不是40000000的数组MLE了
by superMB @ 2019-02-14 11:04:01
@[Eason_AC](/space/show?uid=112917)
评测状态
Unaccepted 0
用时: 2852ms / 内存: 62904KB
编译信息
编译成功
没有编译信息
测试点信息
by AFoxOfZzr @ 2019-02-14 11:05:18
@[superMB](/space/show?uid=118265)
WA了,没有MLE
by AFoxOfZzr @ 2019-02-14 11:05:33
@[AFoxOfZzr](/space/show?uid=118086) 你的逻辑关系反了233333,你把筛到的质数置为1,然而又是为零的时候输出yes
by superMB @ 2019-02-14 11:08:31
@[AFoxOfZzr](/space/show?uid=118086)
我觉得你是想用埃氏筛法吧,我在这里附上我曾经提交AC的代码,供你参考一下:
```cpp
#include <iostream>
#include <cstring>
using namespace std;
const int maxn=1e+7;
bool IsPrime[maxn];
void Essf_Serve () {
memset (IsPrime, true, sizeof (IsPrime));
IsPrime[1] = false;
for (int i = 2; i <= maxn; ++i)
if (IsPrime[i])
for(int j = i*2; j <= maxn; j += i)
IsPrime[j] = false;
}
int main() {
Essf_Serve();
int n, m;
cin >> n >> m;
for(int i = 1; i <= m; ++i) {
int a;
cin >> a;
if(IsPrime[a])
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
```
by Eason_AC @ 2019-02-14 11:10:29
@[Eason_AC](/space/show?uid=112917) w谢谢
by AFoxOfZzr @ 2019-02-14 11:11:36
@[AFoxOfZzr](/space/show?uid=118086) 不谢不谢,~~毕竟我还是个蒟蒻~~
by Eason_AC @ 2019-02-14 11:12:35
@[superMB](/space/show?uid=118265)
刚刚发现了一个问题,
`for(int j=1;j<=k&&prime[j]*i<=m;j++){`
j改成从2开始,然而还是WA,~~awsl~~
by AFoxOfZzr @ 2019-02-14 11:14:04
@[superMB](/space/show?uid=118265) 我就是check==0是素数w
by AFoxOfZzr @ 2019-02-14 11:14:22