标签:using cstring ace algorithm col 线性 += else getc
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; inline int read(){ int num=0,f=1; char c=getchar(); while(!isdigit(c)){if(c==‘-‘) f=-1; c=getchar();} while(isdigit(c)){num=(num<<1)+(num<<3)+(c^48); c=getchar();} return num*f; } #define maxn 10000001 bool prime[maxn+1]; inline int jud(int n){ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ cout<<"NO"; return 0; } } cout<<"YES"; } inline void dark(int n){ for(int i=1;i<=n;i++) if(i&1) prime[i]=1; for(int i=3;i<=n;i+=2) if(prime[i]) for(int j=i+i;j<=n;j+=i) prime[j]=0; // for(int i=2;i<=n;i++) // if(prime[i]) // cout<<i<<" "; prime[2]=1; prime[1]=0; } int main(){ int n,m; scanf("%d%d",&n,&m); dark(n); for(int i=1;i<=m;i++){ int x; scanf("%d",&x); if(prime[x]) cout<<"Yes"<<‘\n‘; else cout<<"No"<<‘\n‘; } }
标签:using cstring ace algorithm col 线性 += else getc
原文地址:http://www.cnblogs.com/79707536wc/p/7808668.html