Advertisement
Brick99

Woburn Challenge 1999 Goldfinger

Mar 23rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. vector <bool> prost(16000,true);
  7.  
  8. void sieve()
  9. {
  10.     for (int i=2;i*i<=16000;i++)
  11.     {
  12.         if (prost[i])
  13.         {
  14.             for (int j=i*2;j<=16000;j+=i)
  15.                 prost[j]=false;
  16.         }
  17.     }
  18. }
  19.  
  20. int main()
  21. {
  22.     int n;
  23.     cin>>n;
  24.  
  25.     sieve();
  26.  
  27.     while (n!=-1)
  28.     {
  29.         int p=0;
  30.  
  31.         if (n%2!=0) p=1;
  32.  
  33.         for (int i=1;i<=n/2+p;i++)
  34.             if (prost[n-i] && prost[i]) cout<<i<<" "<<n-i<<endl;
  35.         cout<<endl;
  36.  
  37.         cin>>n;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement