-
Notifications
You must be signed in to change notification settings - Fork 0
/
Uva-543.cpp
83 lines (75 loc) · 1.65 KB
/
Uva-543.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <bits/stdc++.h>
using namespace std;
#define mid(s,e) (s+(e-s)/2)
#define rff(a) freopen((a), "r", stdin);
#define wtf(a) freopen((a), "w", stdout);
#define ios ios_base::sync_with_stdio(0);
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define sin(s) getline(cin, s)
#define ll long long
#define ull unsigned long long
#define dd double
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<long,long> mll;
typedef map<string,int> msi;
bool ar[10000000];
vector<ll>vl;
void sieve()
{
memset(ar,1,sizeof(ar));
for(ll i=4; i<=10000000; i+=2)
{
ar[i]=0;
}
for(ll i=3; i<=sqrt(10000000); i+=2)
{
if(ar[i])
{
for(ll j=i*i; j<=10000000; j=j+(2*i))
{
ar[j]=0;
}
}
}
}
int main()
{
//freopen("A.txt","r",stdin);
//freopen("A.txt","w",stdout);
ios_base::sync_with_stdio(0);
sieve();
ll n;
while(cin>>n)
{
if(n==0){
return 0;
}
int c=0,k=0,m=0;
for(ll i=2; i<=n/2; i++)
{
if(ar[i] && ar[n-i])
{
c=1;
k=i;
m=n-i;
break;
}
}
if(c)
{
cout<<n<<" = ";
cout<<k<<" + "<<m<<endl;
}
else
{
cout<<n<<" = ";
cout<<"Goldbach's conjecture is wrong."<<endl;
}
}
}