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.
24 lines
566 B
24 lines
566 B
#include<bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 1e8 + 10;
|
|
|
|
//欧拉筛
|
|
int primes[N], cnt; // primes[]存储所有素数
|
|
bool st[N]; // st[x]存储x是否被筛掉
|
|
void get_primes(int n) {
|
|
for (int i = 2; i <= n; i++) {
|
|
if (!st[i]) primes[cnt++] = i;
|
|
for (int j = 0; primes[j] <= n / i; j++) {
|
|
st[primes[j] * i] = true;
|
|
if (i % primes[j] == 0) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int b = 1e8;
|
|
get_primes(b);
|
|
cout << primes[cnt - 1] << endl;
|
|
return 0;
|
|
} |