Advertisement
Hamoudi30

Untitled

May 14th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 509;
  4. int a[N];
  5. int main() {
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(nullptr);
  8.     cout.tie(nullptr);
  9. //    freopen("/home/hamoudi/Coding/run.in", "r", stdin);
  10.     int tt = 1;
  11. //    cin >> tt;
  12.     while (tt--) {
  13.         int n;
  14.         cin >> n;
  15. //        in this case it will be impossible to find  2 primes such that their summation is equal to n
  16.  
  17.         if (n <= 3) {
  18.             cout << -1;
  19.         } else {
  20. //            i will assume that i can find a solution
  21. //            i need to check about n - 2 (where (n - 2) is prime or not)
  22. //            2 + (n - 2) = n so i can fulfill the condition
  23.             bool found = true;
  24.             for (int i = 2; i <= sqrt(n - 2); ++i) {
  25.                 if ((n - 2) % i == 0) {
  26. //                    it can't be a prime in this case
  27.                     found = false;
  28.                     break;
  29.                 }
  30.             }
  31.             if (not found)
  32.                 cout << -1;
  33.             else
  34.                 cout << 2 << " " << n - 2;
  35.         }
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement