-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva10618.cpp
52 lines (46 loc) · 928 Bytes
/
uva10618.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <cstdio>
#include <cmath>
#include <cstring>
const int MAXN = 10000010;
bool u[MAXN];
int su[MAXN];
int num;
void sieve_prime(int n) {
num = 1;
memset(u, true, sizeof(u));
for(int i = 2; i <= n; ++i) {
if(u[i]) su[num++] = i;
for(int j = 1; j < num; ++j) {
if(i*su[j] > n) break;
u[i*su[j]] = false;
if(i % su[j] == 0) break;
}
}
}
int main() {
int n;
n = 10000000;
sieve_prime(n);
int tnum;
while(scanf("%d", &tnum) != EOF) {
if(tnum < 8) printf("Impossible.\n");
else if(tnum == 8) printf("2 2 2 2\n");
else {
if(tnum % 2 == 0) {
tnum -= 4;
printf("2 2 ");
} else {
tnum -= 5;
printf("2 3 ");
}
for(int i = 1; i <= num; ++i) {
if(su[i]*2 > n) break;
if(u[tnum - su[i]]) {
printf("%d %d\n", su[i], tnum-su[i]);
break;
}
}
}
}
return 0;
}