Goldbach's Conjecture
#include<iostream>
#include<cstdio>//pku不支持万能头吗QAQ
using namespace std;
int ifp[1000010],p[1000010];
int main()
{
int cnt=0,n;
ifp[1]=1;
for(int i=2;i<=1000000;i++)
{
if(!ifp[i]) p[++cnt]=i;
for(int j=1;j<=cnt&&i*p[j]<=1000000;j++)//别忘了i*p[j]<=n
{
ifp[i*p[j]]=1;
if(!i%p[j]) break;
}
}
cin>>n;
while(n!=0)
{
for(int i=1;i<=n/2;i++)//直接枚举求出来的i和n-i肯定就是差值最大的
{
if(!ifp[i]&&!ifp[n-i])
{
cout<<n<<" = "<<i<<" + "<<n-i<<"\n";
break;
}
}
cin>>n;
}
// Goldbach’s conjecture is wrong滑稽
}