#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int n, m, vis[10000010], prime[5000010], tot; void init() { for (int i = 2; i <= n; i++) { if (!vis[i]) prime[++tot] = i; for (int j = 1; j <= tot; j++) { int t = i * prime[j]; if (t > n) break; vis[t] = 1; if (i % prime[j] == 0) break; } } } int main() { scanf("%d%d", &n, &m); init(); while (m--) { int t; scanf("%d", &t); if (!vis[t] && t != 1) puts("Yes"); else puts("No"); } return 0; }
时间: 2024-10-08 21:06:33