-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_6588.cpp
More file actions
36 lines (31 loc) · 760 Bytes
/
bj_6588.cpp
File metadata and controls
36 lines (31 loc) · 760 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
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
string print = "Goldbach's conjecture is wrong.\n";
int prime[1000002] = {};
for(int i = 2; i<=1000000; i++) {
if(prime[i] != 1) {
for(int j = 2*i; j<=1000000; j+= i) {
prime[j] = 1;
}
}
}
prime[1] = 1;
prime[2] = 1;
while(N != 0) {
bool check = false;
for(int i = 3; i<= N; i += 2) {
if(prime[i] == 0 && prime[N-i] == 0) {
cout << N << " = " << i << " + " << (N-i) << "\n";
check = true;
break;
}
}
if(check == false) {
cout << print;
}
cin >> N;
}
}