#include<bits/stdc++.h>
#define sf scanf
#define pf printf
#define LL long long
#define REP(i,MAX) for(int i = 0; i<MAX; i++)
#define MAX 20000010
using namespace std;
bool prime[MAX];
vector<int> P;
vector<int>TwinPrime;
void init_prime() {
prime[2] = true;
for (int i = 3; i < MAX; i += 2) prime[i] = true;
for (int i = 3; i*i < MAX; i += 2)
if (prime[i])
for (int j = i*i; j < MAX; j += i+i)
prime[j] = false;
REP(i, MAX)if (prime[i]) P.push_back(i);
for (int i = 0; i <P.size(); i++)
{
if(P[i+1]-P[i] == 2)TwinPrime.push_back(P[i]);
}
}
int main()
{
ios_base::sync_with_stdio(false);
init_prime();
int n;
while(cin >> n){
cout <<'('<<TwinPrime[n-1]<<", "<<TwinPrime[n-1]+2<<")\n";
}
return 0;
}
#define sf scanf
#define pf printf
#define LL long long
#define REP(i,MAX) for(int i = 0; i<MAX; i++)
#define MAX 20000010
using namespace std;
bool prime[MAX];
vector<int> P;
vector<int>TwinPrime;
void init_prime() {
prime[2] = true;
for (int i = 3; i < MAX; i += 2) prime[i] = true;
for (int i = 3; i*i < MAX; i += 2)
if (prime[i])
for (int j = i*i; j < MAX; j += i+i)
prime[j] = false;
REP(i, MAX)if (prime[i]) P.push_back(i);
for (int i = 0; i <P.size(); i++)
{
if(P[i+1]-P[i] == 2)TwinPrime.push_back(P[i]);
}
}
int main()
{
ios_base::sync_with_stdio(false);
init_prime();
int n;
while(cin >> n){
cout <<'('<<TwinPrime[n-1]<<", "<<TwinPrime[n-1]+2<<")\n";
}
return 0;
}
No comments:
Post a Comment