Goldbach's Conjecture(哥德巴赫猜想)
Goldbach's Conjecture
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5277 Accepted Submission(s):
2022
点我
than or equal to 4, there exists at least one pair of prime numbers p1 and p2
such that n = p1 + p2.
This conjecture has not been proved nor refused yet.
No one is sure whether this conjecture actually holds. However, one can find
such a pair of prime numbers, if any, for a given even number. The problem here
is to write a program that reports the number of all the pairs of prime numbers
satisfying the condition in the conjecture for a given even number.
A
sequence of even numbers is given as input. Corresponding to each number, the
program should output the number of pairs mentioned above. Notice that we are
interested in the number of essentially different pairs and therefore you should
not count (p1, p2) and (p2, p1) separately as two different pairs.
that each integer is even, and is greater than or equal to 4 and less than 2^15.
The end of the input is indicated by a number 0.
other characters should appear in the output.
#include <iostream>
using namespace std;
int a[];
int isprime()
{
int i,k,x;
for(i=;i<;i++)
{
for(k=;k<=i/;k++)
{
if(i%k==)
break;
}
if(k==i/+)
a[i]=;
else
a[i]=;
}
return ;
}
int main()
{
int x,i,j,count=;
isprime();
while(cin>>x&&x)
{
count=;
for(i=j=x/;i>=;i--,j++)
{
if(a[i]&&a[j])
{
count++;
}
}
cout<<count<<endl;
}
}
Goldbach's Conjecture(哥德巴赫猜想)的更多相关文章
- LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)
http://lightoj.com/volume_showproblem.php?problem=1259 题目大意:给你一个数n,这个数能分成两个素数a.b,n = a + b且a<=b,问 ...
- Goldbach's Conjecture POJ - 2262 线性欧拉筛水题 哥德巴赫猜想
题意 哥德巴赫猜想:任一大于2的数都可以分为两个质数之和 给一个n 分成两个质数之和 线行筛打表即可 可以拿一个数组当桶标记一下a[i] i这个数是不是素数 在线性筛后面加个装桶循环即可 #inc ...
- Goldbach`s Conjecture LightOJ - 1259 (素数打表 哥德巴赫猜想)
题意: 就是哥德巴赫猜想...任意一个偶数 都可以分解成两个(就是一对啦)质数的加和 输入一个偶数求有几对.. 解析: 首先! 素数打表..因为 质数 + 质数 = 偶数 所以 偶数 - 质数 = 质 ...
- HDOJ 1397 Goldbach's Conjecture(快速筛选素数法)
Problem Description Goldbach's Conjecture: For any even number n greater than or equal to 4, there e ...
- 【LightOJ1259】Goldbach`s Conjecture(数论)
[LightOJ1259]Goldbach`s Conjecture(数论) 题面 Vjudge T组询问,每组询问是一个偶数n 验证哥德巴赫猜想 回答n=a+b 且a,b(a<=b)是质数的方 ...
- LightOJ1259 Goldbach`s Conjecture —— 素数表
题目链接:https://vjudge.net/problem/LightOJ-1259 1259 - Goldbach`s Conjecture PDF (English) Statistic ...
- Light oj-1259 - Goldbach`s Conjecture
1259 - Goldbach`s Co ...
- Goldbach`s Conjecture(LightOJ - 1259)【简单数论】【筛法】
Goldbach`s Conjecture(LightOJ - 1259)[简单数论][筛法] 标签: 入门讲座题解 数论 题目描述 Goldbach's conjecture is one of t ...
- Goldbach’s Conjecture(信息学奥赛一本通 1622)
[题目描述] 原题来自:Ulm Local,题面详见:POJ 2262 哥德巴赫猜想:任何大于 44 的偶数都可以拆成两个奇素数之和. 比如: 8=3+5 20=3+17=7+13 42=5+37=1 ...
随机推荐
- [XMPP]简易的聊天室实现[二](使用CocoaAsyncSocket)
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- 添加事件监听兼容IE6-8
IE8一下浏览器不支持addEventListener,用attachEvent取而代之,但是在时间类型前面要加上’on‘,例如click时间在attachEvent中要写成onclick. var ...
- android sdk 如何重新生成debug.keystore
1)首先你要确定你安装的JDK位置,Windows->Preferences->Java->Installed JREs,你可以看到是Jre的location,再在dos cmd模式 ...
- python list列表 方法总结
深入链表(most on lists) The list data type has some more methods. Here are all of the methods of list ob ...
- spring3.0事务的配置
第一种配置方法:基于XML的事务管理 这种方法不需要对原有的业务做任何修改,通过在XML文件中定义需要拦截方法的匹配即可完成配置,要求是,业务处理中的方法的命名要有规律,比如setXxx,xxxUpd ...
- mongodb导入导出备份恢复
mongodb数据库同样离不开必要的维护,如备份.恢复.导入.导出. 其实备份和恢复比导入和导出要方便些,而且一般不会出错,所以大部分时候使用备份和恢复操作就可以了 1. 备份Mongodb mong ...
- java编译相关问题总结
参考:http://jingyan.baidu.com/article/5bbb5a1b080f6113eba179f0.html 1.在linux下生成的class文件/jar包,拿到windows ...
- HTTP学习笔记
最近在看HTTP权威指南, 然后准备从Python的request库入手,看它的源代码实现 http://cn.python-requests.org/zh_CN/latest/ 挖坑 今年准备在gi ...
- oracle 库文件解决的方法 bad ELF interpreter: No such file or directory
今天是2014-05-27,今天遇到一个lib问题,再次记录一下.这是一个案例,更是一种解决该问题的方法过程. 当我们在使用sqlplus 登陆unix数据库的时候,有可能出现类似:xxxxxx ba ...
- 设置MySQL数据表主键
设置MySQL数据表主键: 使用“primary key”关键字创建主键数据列.被设置为主键列不允许出现重复的值,很多情况下与“auto_increment”递增数字相结合.如下SQL语句所示: My ...