用欧拉筛把素数筛出来,再枚举一下。
#include<iostream>
#include<cstdio>
#include<cstring>
#define re register
using namespace std;
#define N 1000001
int n,v[N],pri[N],cct; bool is[N];
int main(){
for(int i=;i<N;++i){
if(!v[i]) is[v[i]=pri[++cct]=i]=;
for(int j=;j<=cct;++j){
if(pri[j]>i||pri[j]*i>=N) break;
v[pri[j]*i]=pri[j];
}
}
while(scanf("%d",&n)){
if(!n) return ;
bool flag=;
for(int i=;i<=cct&&flag;++i)
if(is[i]&&is[n-i])
printf("%d = %d + %d\n",n,i,n-i),flag=;
if(flag) puts("Goldbach's conjecture is wrong.");
}return ;
}