problem
- 给定一个范围N
- 回答M个某数字是否为质数的询问(M
solution
codes
#include<iostream>
#define maxn 10000010
using namespace std;
int pri[maxn];
int main(){
int n, m; cin>>n>>m;
pri[1] = 1;
for(int i = 2; i*i <= n; i++)
if(!pri[i])
for(int j = 2*i; j <= n; j += i)
pri[j] = 1;
for(int i = 1; i <= m; i++){
int x; cin>>x;
if(!pri[x])cout<<"Yes
";
else cout<<"No
";
}
return 0;
}