标签:void iostream ems algorithm scan ++ als bool can
1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 #include <cstdio> 5 6 const int MAX_N = 10000000 + 10; 7 8 bool vis[MAX_N]; 9 int Prime[MAX_N >> 1]; 10 inline void GetPrime(int n) { 11 memset(vis, false, sizeof(vis)); 12 vis[1] = true; 13 14 int cnt = 0; 15 for (int i = 2; i <= n; i++) { 16 if (!vis[i]) Prime[++cnt] = i; 17 for (int j = 1; j <= cnt && i * Prime[j] <= n; j++) { 18 vis[i * Prime[j]] = true; 19 if (i * Prime[j] == 0) break; 20 } 21 } 22 } 23 24 int main() { 25 int n, m; scanf("%d%d", &n, &m); 26 27 GetPrime(n); 28 while (m--) { 29 int x; scanf("%d", &x); 30 if (!vis[x]) puts("Yes"); 31 else puts("No"); 32 } 33 34 return 0; 35 }
标签:void iostream ems algorithm scan ++ als bool can
原文地址:https://www.cnblogs.com/wky1366365447/p/9920809.html