Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef _MSC_VER
- #define _CRT_SECURE_NO_WARNINGS 1
- #endif
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- const int maxVal = 10e7;
- bool sieve[maxVal];
- int main()
- {
- // Load sieve array.
- sieve[0] = true;
- sieve[1] = true;
- for (int i = 2; i*i <= maxVal; i++)
- if (!sieve[i])
- for (int j = i*2; j < maxVal; j += i)
- sieve[j] = true;
- int n;
- while (scanf("%d", &n) != EOF)
- {
- if (n < 8)
- cout << "Impossible.\n";
- else
- {
- int remainder;
- if (n % 2 == 0)
- {
- cout << "2 2 ";
- remainder = n - 4;
- }
- else
- {
- cout << "2 3 ";
- remainder = n - 5;
- }
- for (int i = 2; i < remainder; i++)
- {
- int rmi = remainder - i;
- if (!sieve[i] && !sieve[rmi])
- {
- cout << i << " " << rmi << "\n";
- break;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement