Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main(){
- ios::sync_with_stdio(0); cin.tie(0);
- int N=20000000;
- vector<bool> prime(N+1,1);
- int last=2;
- vector<pair<int,int>> twin;
- for(int p=3; p<=N; p+=2){
- if(prime[p]){
- if(p-last==2) twin.push_back({last,p});
- last=p;
- for(int i=2*p; i<=N; i+=p){
- prime[i]=0;
- }
- }
- }
- int n;
- while(cin>>n){
- auto p=twin[n-1];
- printf("(%d, %d)\n",p.first,p.second);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement