-
Notifications
You must be signed in to change notification settings - Fork 2
/
10168.cpp
62 lines (50 loc) · 750 Bytes
/
10168.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
53
54
55
56
57
58
59
60
61
62
#include<stdio.h>
#include<math.h>
# define MAXN 10000000
char p[MAXN+3];
int prime_table()
{
int i,j;
p[1] = 0;
for(i = 2; i<=MAXN; i ++) p[i] = 1;
for(i = 2; i<sqrt(MAXN); )
{
for(j = i+i; j<=MAXN; j += i)
p[j] = 0;
for(i ++; !p[i]; i ++);
}
return 0;
}
int even(int n)
{
int i,j;
if(n == 4) {
printf("2 2\n");
return 1;
}
for(i = 3,j = n-3; i<=j; i++,j--)
if(p[i] && p[j]) {
printf("%d %d\n", i,j);
return 1;
}
return 0;
}
int main() {
int n,a,b,k;
prime_table();
while(scanf("%d", &n) == 1) {
if( n < 8 ) {
printf("Impossible.\n");
continue;
}
if(n % 2 == 0) {
printf("2 2 ");
even(n-4);
}
else {
printf("2 3 ");
even(n-5);
}
}
return 0;
}