Files
python/TangDou/LuoGuBook/P5723_Test_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

20 lines
446 B
C++

#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
int check[N];//元素值为0代表是素数
int prime[N];
int main() {
int cnt = 0;
for (int i = 2; i < N; i++) {
//如果是素数
if (!check[i]) prime[cnt++] = i;
//筛出成倍的合数
for (int j = 2 * i; j < N; j += i) check[j] = 1;
}
printf("%.2f", (double) clock() / CLOCKS_PER_SEC);
return 0;
}