-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10394.cpp
More file actions
45 lines (41 loc) · 751 Bytes
/
Copy path10394.cpp
File metadata and controls
45 lines (41 loc) · 751 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
#include <cstdio>
#include <iostream>
#include <vector>
#define LIM 2*1e7
using namespace std;
vector< pair<int,int> > pp;
vector<bool> isPrime(LIM+3,true);
void criba()
{
isPrime[0]=isPrime[1]=0;
long long ant=-1;
for( long long i = 2 ; i < LIM ; ++i )
{
if(isPrime[i])
{
// cout<<i<<" "<<ant<<endl;
if( i != 2 && i-ant == 2 )
{
pp.push_back(make_pair(ant,i));
}
ant = i;
for(long long j = i*i ; j < LIM ; j+=i )
{
// cout<<"-- j "<<j<<endl;
isPrime[j]=false;
}
}
}
}
int main()
{
criba();
// cout<<"hola "<<pp.size()<<endl;
int n;
while( scanf("%d",&n)!=EOF)
{
n--;
printf("(%d, %d)\n",pp[n].first,pp[n].second);
}
return 0;
}