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
451 B
20 lines
451 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 1000000;
|
|
int prime[N];
|
|
|
|
int main() {
|
|
int idx;
|
|
int flag;
|
|
for (int i = 2; i < N; i++) {
|
|
flag = 1;
|
|
for (int j = 2; j * j < i; j++) //会快很多
|
|
// for (int j = 2; j < sqrt(i); j++)
|
|
if (i % j == 0) flag = 0;
|
|
if (flag == 1) prime[idx++] = i;
|
|
}
|
|
printf("%.2f", (double) clock() / CLOCKS_PER_SEC);
|
|
return 0;
|
|
}
|