社区讨论
代替犇犇发消息
灌水区参与者 14已保存回复 17
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 17 条
- 当前快照
- 1 份
- 快照标识符
- @mi6y20oq
- 此快照首次捕获于
- 2025/11/20 12:41 4 个月前
- 此快照最后确认于
- 2025/11/20 15:25 4 个月前
高天昊
注意接收
CPP#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int p[10001000],m,n,tot=0;
bool isp[10001000];
int main(){
scanf("%d%d",&n,&m);
memset(isp,true,sizeof(isp));
isp[0]=isp[1]=false;
for(int i=2;i<=n;i++){
if(isp[i])p[++tot]=i;
for(int j=1;j<=tot&&i*p[j]<=n;j++){
isp[i*p[j]]=false;
if(!(i%p[j]))break;
}
}
for(int i=1;i<=m;i++){
int j;
scanf("%d",&j);
if(isp[j])printf("Yes\n");
else printf("No\n");
}
return 0;
}
回复
共 17 条回复,欢迎继续交流。
正在加载回复...