#include<cstdio> using namespace std; //素数判定 bool cheak1_1(int n) { for (int i = 2; i * 2 <= n; i++) if (n % i == 0) return 0; return 1; } bool cheak1_2(int n) { int lim = (int) sqrt(n) + 1; for (int i = 2; i <= lim; i++) if (n % i == 0) return 0; return 1; } //素数筛法 bool cheak2_1(int n) { for (int i = 2; i <= n; i++) if (!pd[i]) for (int j = i + i; j <= n; j += i) pd[j] = 1; } bool cheak2_2(int n) { for (int i = 2; i <= n; i++) { if (!vis[i]) prim[++num] = i; for (int j = 1; j <= num && pr[j] * i <= n; j++) { vis[pr[j] * i] = 1; if (i % pr[j] == 0) break; } } }