10394

#include <iostream>
#include <string>
#include <vector>
#include <math.h>

#define SZ 20000001

using namespace std;

int prime[SZ];
vector<int> v;

struct twin{
	int x;
	int y;
}twinPrime[108001];

void primegen()
{
	double p = sqrt(SZ);

	for(int i=3;i<p;i+=2)
	{
		if(prime[i]==0)
		{
			for(int j=i*i;j<SZ;j+=i)
				prime[j]=1;
		}
	}

	v.push_back(2);
	int cnt=0;
	for(int i=3;i<SZ;i+=2)
	{
		if(prime[i]==0)
		{
			v.push_back(i);
			int t=v.size();
			if(v[t-1]-v[t-2]==2)
			{
				twinPrime[cnt].x = v[t-2];
				twinPrime[cnt].y = v[t-1];
				cnt++;
			}
		}
	}
}


int main()
{
	primegen();
	int size = v.size();
	int n;

	while(cin>>n)
	{
		cout<<"("<<twinPrime[n-1].x<<", "<<twinPrime[n-1].y<<")\n";
	}
	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *