题目地址


易错点:


#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN=10000010;
bool vis[MAXN];
void primes(int x){
	for(int i=1;i<=sqrt(x);i++){
		if(vis[i])continue;
		for(int j=i;j<=x/i;j++){
			vis[i*j]=1;
		}
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	vis[1]=1;
	primes(n);
	for(int i=1;i<=m;i++){
		int tmp;
		scanf("%d",&tmp);
		if(!vis[tmp])printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}