标签:线性 cin include stream code pre style col cstring
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> using namespace std; int n,m,jdg[10000001],prime[10000001],cnt; int main() { cin>>n>>m; jdg[1]=1; for(int i=2;i<=n;i++) { if(jdg[i]==0) prime[++cnt]=i; for(int j=1;j<=cnt;j++) { if(prime[j]*i>n) break; jdg[i*prime[j]]=1; if(i%prime[j]==0) break; } } for(int i=1;i<=m;i++) { int a; cin>>a; if(jdg[a]==0) cout<<"Yes"<<endl; else cout<<"No"<<endl; } }
标签:线性 cin include stream code pre style col cstring
原文地址:https://www.cnblogs.com/water-radish/p/9280652.html