标签:blog io ar os for div log amp ef
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<cstdlib> #include<algorithm> #include<queue> #include<vector> #include<set> #define N 1000000 bool p[N]; int n,Max; void prime() { p[0]=0,p[1]=0,p[2]=1; Max=(int)sqrt(N*1.0); for(int i=3;i<=N;i++) p[i]=i%2==0?0:1; for(int i=3;i<=Max;i++) if(p[i]) { for(int j=i*i;j<=N;j+=2*i) p[j]=0; } } int main() { prime(); while(scanf("%d",&n)!=EOF) { if(p[n]) printf("YES\n"); else printf("NO\n"); } return 0; }
标签:blog io ar os for div log amp ef
原文地址:http://www.cnblogs.com/a972290869/p/4099527.html