天涯人论坛
先登录吧!!!
登录可以体验更多权限哦!!!
天涯人论坛
先登录吧!!!
登录可以体验更多权限哦!!!
天涯人论坛
Would you like to react to this message? Create an account in a few clicks or log in to continue.
天涯人论坛

为编程爱好者打造一个学习、交流的平台。
 
首页首页  欢迎页欢迎页  Latest imagesLatest images  注册注册  登录登录  
论坛刚刚起步,欢迎大家多多支持! 如果有想申请管理员或版主的请给管理员留言!!!
欢迎大家积极发帖!

 

 哥德巴赫曾猜测

向下 
作者留言
让一切随风
Admin
让一切随风


帖子数 : 257
注册日期 : 12-11-03
年龄 : 32
地点 : 湖南

哥德巴赫曾猜测 Empty
帖子主题: 哥德巴赫曾猜测   哥德巴赫曾猜测 Empty周六 四月 20, 2013 8:54 pm

【哥德巴赫曾猜测】



Time Limit:10000MS Memory Limit:65536K

Total Submit:971 Accepted:325



Description



德国数学家哥德巴赫曾猜测:任何大于6的偶数都可以分解成两个素数(素数对)的和。但有些偶数可以分解成多种素数对的和,如: 10=3+710=5+5,即10可以分解成两种不同的素数对。



Input



输入任意的>6的正偶数(<32767)



Output



试求给出的偶数可以分解成多少种不同的素数对(注: A+BB+A认为是相同素数对)



Sample Input





1234



Sample Output





25



代码:



[font='Times New Roman']#include<iostream>[/font]

[font='Times New Roman']#include<cmath>[/font]

[font='Times New Roman']using namespace std;[/font]

[font='Times New Roman']int main()[/font]

[font='Times New Roman']{[/font]

[font='Times New Roman']int primer(int x);[/font]

[font='Times New Roman']int t=0,n,i;[/font]

[font='Times New Roman']cin>>n;[/font]

[font='Times New Roman']for(i=3;i<=n/2;i+=2)[/font]

[font='Times New Roman']if(primer(i))[/font]

[font='Times New Roman']if(primer(n-i))[/font]

[font='Times New Roman']t++;[/font]

[font='Times New Roman']cout<<t<<endl;[/font]

[font='Times New Roman']return 0;[/font]

[font='Times New Roman']}[/font]

[font='Times New Roman']int primer(int x)[/font]

[font='Times New Roman']{[/font]

[font='Times New Roman']int m,i;[/font]

[font='Times New Roman']m=(int)(sqrt(x));[/font]

[font='Times New Roman']for(i=2;i<=m;i++)[/font]

[font='Times New Roman']if(x%i==0) break;[/font]

[font='Times New Roman']if(i>m) return 1;[/font]

[font='Times New Roman']else return 0;[/font]

[font='Times New Roman']}[/font]

返回页首 向下
http://tyren.longluntan.org
 
哥德巴赫曾猜测
返回页首 
1页/共1

您在这个论坛的权限:不能在这个论坛回复主题
天涯人论坛 :: 我爱编程 :: c语言-
转跳到: