强推洛谷日报
写的超棒!
(洛谷日报里的文章都超好
(所以我就不说什么了
#include<cstdio> #include<cstring> using namespace std; #define maxn 10000010 int n,num; bool prime[maxn]; int PRIME[maxn]; void make_prime(){ memset(prime,true,sizeof(prime)); prime[0] = prime[1] = false; for(int i = 2;i <= n;i++){ if(prime[i]) PRIME[num++] = i; for(int j = 0;j <= num && i * PRIME[j] <= n;j++){ prime[i * PRIME[j]] = false; if(!(i % PRIME[j])) break; } } return ; } int main(){ int m; scanf("%d%d",&n,&m); make_prime(); for(int i = 0;i < m;i++){ int x; scanf("%d",&x); if(prime[x])printf("Yes "); else printf("No "); } return 0; }
//一定要记住怎么写啊【哭唧唧
//我怎么这么水啊【丧