-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path543.cpp
More file actions
executable file
·39 lines (39 loc) · 729 Bytes
/
543.cpp
File metadata and controls
executable file
·39 lines (39 loc) · 729 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int const N=1e6+9;
bool prime[N];
void fun()
{
memset(prime,true,sizeof(prime));
prime[1]=false;
prime[0]=false;
for(int i=2; i*i<=N; i++)
{
if(prime[i])
{
for(int j=i*i; j<=N; j+=i)prime[j]=false;
}
}
}
int main()
{
fun();
while(true)
{
int n;
cin>>n;
if(n==0)return 0;
bool ok=true;
for(int i=2; i<=n/2; i++)
{
if(prime[i]&&prime[n-i])
{
cout<<n<<" = "<<i<<" + "<<n-i<<endl;
ok=false;
break;
}
}
if(ok)
cout<<"Goldbach's conjecture is wrong.\n";
}
}