using namespace std;
#define n 20000005
long long int twin[n];
bool a[n];
void sieve()
{
long long int i,j,k=1;
a[0]=a[1]=1;
for(i=4;i<n;i=i+2)
{
a[i]=1;
}
for(i=3;i<sqrt(n);i=i+2)
{
for(j=i*i;j<n;j=j+2*i)
{
a[j]=1;
}
}
for(i=2;i<n;i++)
{
if(a[i]==0 && a[i+2]==0)
{
twin[k]=i;
k++;
}
}
}
int main()
{
long long int m;
sieve();
while(cin>>m)
{
cout<<"("<<twin[m]<<", "<<twin[m]+2<<")"<<endl;
}
return 0;
}
0 comments:
Post a Comment