You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
446 B
20 lines
446 B
#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;
|
|
}
|