-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10948_ThePrimaryProblem.cpp
65 lines (55 loc) · 1.01 KB
/
10948_ThePrimaryProblem.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
63
64
65
using namespace std;
#include<iostream>
#include<cstring>
#include<cmath>
#define n 1000010
long long int c,j,k,arr[1050];
int prime[n];
void primeFIND()
{
k=0;
memset(prime , 0 , sizeof prime);
prime[0]=prime[1]=1;
for(c=2; c<=sqrt(n) ; c++)
{
if(!prime[c])
{
for(j=c*c; j<=n ;j=j+c)
{
prime[j]=1;
}
arr[k++]=c;
}
}
}
int main()
{
long long int N,temp,flag,l;
primeFIND();
while(cin>>N&&N)
{
temp=2;
l=1;
flag=1;
while(N-temp>=temp)
{
if(!prime[temp]&&!prime[N-temp])
{
flag=0;
break;
}
temp=arr[l++];
}
cout<<N<<":"<<endl;
if(flag)
cout<<"NO WAY!"<<endl;
else
{
if(temp<N-temp)
cout<<temp<<"+"<<N-temp<<endl;
else
cout<<N-temp<<"+"<<temp<<endl;
}
}
return 0;
}