-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler7.cpp
More file actions
46 lines (35 loc) · 762 Bytes
/
Copy patheuler7.cpp
File metadata and controls
46 lines (35 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll upper_bound_primo(ll n)
{
if(n < 6)
return 100;
return ceil(n * (log(n) + log(log(n))));
}
ll sieve(ll n)
{
bool primo[n + 1];
memset(primo, true, sizeof(primo));
for(int p = 2; p*p <= n; p++)
if(primo[p] == true)
for(int i = p*p; i <=n; i+=p)
primo[i] = false;
ll cont = 0;
for(int p = 2; p <= n; p++)
if(primo[p] == true)
{
cont++;
if(cont == 10001)
return p;
}
return 0;
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
ll upBound = upper_bound_primo(10001);
cout << sieve(upBound)<< endl;
return 0;
}