信息学奥赛一本通——哥德巴赫猜想

**

信息学奥赛一本通——哥德巴赫猜想

http://ybt.ssoier.cn:8088/problem_show.php?pid=1157

哥德巴赫猜想

上面是题目

#include
#include
using namespace std;
bool judge(int x);

int main()
{
int x;
int i;

for(x=6;x<=100;x+=2)
	for(i=2;i<=x/2;i++)
		if(judge(i)&&judge(x-i))
		{
			cout<<x<<"="<<i<<"+"<<x-i<<endl;
			break;
		}
return 0;

}

bool judge(int x)
{
int i=2;
while(i<=floor(sqrt(x))&&(x%i!=0))
i++;
if(i>floor(sqrt(x)))
return true;
return false;
}

发布了4 篇原创文章 · 获赞 1 · 访问量 85

猜你喜欢

转载自blog.csdn.net/weixin_43418868/article/details/105639829
今日推荐