-
Notifications
You must be signed in to change notification settings - Fork 0
/
Euler007.cpp
60 lines (57 loc) · 1.22 KB
/
Euler007.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ****GT_18**** */
#include<bits/stdc++.h>
#define MIN(a,b,c) min(min(a,b),c)
#define MAX(a,b,c) max(max(a,b),c)
#define ll long long
#define itr vector<int>::iterator
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define all(a) (a).begin(),(a).end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define hell 1000000007
#define endl '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
using namespace std;
int N=1000005;
vi isPrime(N+1),primes;
void sieve()
{
for(int i = 0; i <= N;++i)
{
isPrime[i] = 1;
}
isPrime[0] = 0;
isPrime[1] = 0;
for(int i = 2; i <= N; ++i)
{
if(isPrime[i] == 1)
{
primes.pb(i);
for(int j = i * 2; j <= N ;j += i)
isPrime[j] = 0;
}
}
}
int main()
{
sieve();
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
cin>>t;
while(t--)
{
ll n,ans=1;
cin>>n;
cout<<primes[n-1]<<endl;
}
return 0;
}