Advertisement
O_Egor

67

May 18th, 2022
800
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main()
  7. {  
  8.    
  9.     vector<char> prime(10000001, true);
  10.     prime[0] = prime[1] = false;
  11.     for (int i = 2; i <= 10000000; ++i)
  12.         if (prime[i])
  13.             if (i * 1ll * i <= 10000000)
  14.                 for (int j = i * i; j <= 10000000; j += i)
  15.                     prime[j] = false;
  16.  
  17.     for (int i = 3000000; i < 10000000 - 1; ++i)
  18.     {
  19.        
  20.         if (prime[i] && prime[i + 2])
  21.         {
  22.             cout << i << ' ' << i + 2 << '\n';
  23.         }
  24.     }
  25.     return 0;
  26. }
Advertisement
RAW Paste Data Copied
Advertisement