C/C++程序训练6---歌德巴赫猜想的证明
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
验证“每个不小于6的偶数都是两个素数之和”,输入一个不小于6的偶数n,找出两个素数,使它们的和为n。
Input
输入一个不小于6的偶数n。
Output
找出两个素数,使它们的和为n。只需要输出其中第一个素数最小的一组数据即可。
Example Input
80
Example Output
80=7+73
#include<stdio.h>
int main()
{
long int x,y,z,j;
scanf("%ld" , &x);
y=x;
for(z=3;z<y;z++)
{
y=x-z;
for(j=2;j<=z-1;j++)
{
if(z%j==0)
break;
}
if(j<z)continue;
for(j=2;j<=y-1;j++)
{
if(y%j==0)
break;
}
if(j<y)continue;
printf("%ld=%ld+%ld",x,z,y);
break;
}
return 0;
}