Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- typedef long long int ll;
- vector<int> p;
- void erat(int n) {
- vector<int> sieve(n);
- for (int i=0;i<n;i++) sieve[i]=i;
- p.clear();
- for (ll i=2;i<n;i++) {
- if (sieve[i]==i) p.push_back(i);
- for (ll j=0;j<p.size() && p[j]<=sieve[i] && p[j]*i<n;j++)
- sieve[p[j]*i]=p[j];
- }
- }
- int main () {
- int n;
- cin >> n;
- erat(n);
- for (int i=0,j=p.size()-1;i<=j;(p[i]+p[j]<n)?i++:j--)
- if (p[i]+p[j]==n) {
- cout << p[i] << ' ' << p[j];
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment