forked from Badhansen/UVa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10168 - Summation of Four Primes.cpp
More file actions
55 lines (50 loc) · 1.26 KB
/
10168 - Summation of Four Primes.cpp
File metadata and controls
55 lines (50 loc) · 1.26 KB
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
/**
Badhan Sen
Student of C.S.E
jessore University of Science & Technology
Mail: galaxybd9@gmail.com
*/
#include<bits/stdc++.h>
using namespace std;
bool dp[10000001];
int main ()
{
long long int n, m, i, j, a, mx;
mx=sqrt(10000000);
for (i=4;i<=10000000;i+=2){
dp[i]=1;
}
for (j=3;j<=mx;j+=2){
if (dp[j]==0){
for (a=j*j;a<=10000000;a+=j){
dp[a]=1;
}
}
}
while (scanf ("%lld", &n)!=EOF){
long long int ck, pk;
if (n%2==0 && n>7){
ck=n-4;
for (i=2; i<=ck/2; i++){
if (dp[ck-i]==0 && dp[i]==0){
printf ("2 2 %lld %lld\n", ck-i, i);
break;
}
}
}
else {
if (n<8)
cout << "Impossible." << endl;
else {
ck=n-5;
for (i=2;i<=ck/2;i++){
if (dp[ck-i]==0 && dp[i]==0){
printf ("2 3 %lld %lld\n", i, ck-i);
break;
}
}
}
}
}
return 0;
}