#include<bits/stdc++.h>
#define N 18410000
using namespace std;
int p[N+1];
int b[100001];
int c[100001];
vector<int>a;
void prime()
{
int l, i, j;
l = sqrt(N);
p[1] = 1;
a.push_back(2);
for(i=4;i<=N;i+=2)
{
p[i] = 1;
}
for(i=3;i<=N;i+=2)
{
if(p[i] == 0)
{
a.push_back(i);
if(i<=l)
{
for(j=i*i;j<=N;j+=i*2)
p[j] = 1;
}
}
}
}
void anik()
{
int i, j = 0;
for(i=0;i<a.size();i++)
{
if(a[i+1] - a[i] == 2)
{
b[j] = a[i];
c[j] = a[i+1];
j++;
if(j == 100000)
break;
}
}
}
int main()
{
prime();
anik();
int n, m;
while(cin >> n)
{
cout << "(" << b[n-1] << ", " << c[n-1] << ")" << endl;
}
return 0;
}
#define N 18410000
using namespace std;
int p[N+1];
int b[100001];
int c[100001];
vector<int>a;
void prime()
{
int l, i, j;
l = sqrt(N);
p[1] = 1;
a.push_back(2);
for(i=4;i<=N;i+=2)
{
p[i] = 1;
}
for(i=3;i<=N;i+=2)
{
if(p[i] == 0)
{
a.push_back(i);
if(i<=l)
{
for(j=i*i;j<=N;j+=i*2)
p[j] = 1;
}
}
}
}
void anik()
{
int i, j = 0;
for(i=0;i<a.size();i++)
{
if(a[i+1] - a[i] == 2)
{
b[j] = a[i];
c[j] = a[i+1];
j++;
if(j == 100000)
break;
}
}
}
int main()
{
prime();
anik();
int n, m;
while(cin >> n)
{
cout << "(" << b[n-1] << ", " << c[n-1] << ")" << endl;
}
return 0;
}
Comments
Post a Comment