标签:printf include 线性筛 can nbsp class turn code span
传送门:线性筛素数
Prime:
1 #include<cstdio> 2 3 const int MAXN = 10000100; 4 int Prime[MAXN],n,m,Size; 5 bool Vis[MAXN]={1,1}; 6 7 int main() 8 { 9 scanf("%d%d",&n,&m); 10 for(int i=2;i<n;i++) 11 { 12 if(!Vis[i]) 13 Prime[++Size]=i; 14 for(int j=1;j<=Size&&Prime[j]<=i&&Prime[j]*i<=n;j++) 15 Vis[Prime[j]*i]=1; 16 } 17 for(int i=1,Que;i<=m;i++) 18 { 19 scanf("%d",&Que); 20 if(Vis[Que]) printf("No\n"); 21 else printf("Yes\n"); 22 } 23 return 0; 24 }
标签:printf include 线性筛 can nbsp class turn code span
原文地址:http://www.cnblogs.com/Never-See/p/6387115.html