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

点我

Problem Description
Goldbach's Conjecture: For any even number n greater
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.

 
Input
An integer is given in each input line. You may assume
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.
 
Output
Each output line should contain an integer number. No
other characters should appear in the output.
 
Sample Input
6
10
12
0
 
Sample Output
1
2
1
 #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(哥德巴赫猜想)的更多相关文章

  1. LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)

    http://lightoj.com/volume_showproblem.php?problem=1259 题目大意:给你一个数n,这个数能分成两个素数a.b,n = a + b且a<=b,问 ...

  2. Goldbach's Conjecture POJ - 2262 线性欧拉筛水题 哥德巴赫猜想

    题意 哥德巴赫猜想:任一大于2的数都可以分为两个质数之和 给一个n 分成两个质数之和 线行筛打表即可 可以拿一个数组当桶标记一下a[i]  i这个数是不是素数  在线性筛后面加个装桶循环即可 #inc ...

  3. Goldbach`s Conjecture LightOJ - 1259 (素数打表 哥德巴赫猜想)

    题意: 就是哥德巴赫猜想...任意一个偶数 都可以分解成两个(就是一对啦)质数的加和 输入一个偶数求有几对.. 解析: 首先! 素数打表..因为 质数 + 质数 = 偶数 所以 偶数 - 质数 = 质 ...

  4. HDOJ 1397 Goldbach's Conjecture(快速筛选素数法)

    Problem Description Goldbach's Conjecture: For any even number n greater than or equal to 4, there e ...

  5. 【LightOJ1259】Goldbach`s Conjecture(数论)

    [LightOJ1259]Goldbach`s Conjecture(数论) 题面 Vjudge T组询问,每组询问是一个偶数n 验证哥德巴赫猜想 回答n=a+b 且a,b(a<=b)是质数的方 ...

  6. LightOJ1259 Goldbach`s Conjecture —— 素数表

    题目链接:https://vjudge.net/problem/LightOJ-1259 1259 - Goldbach`s Conjecture    PDF (English) Statistic ...

  7. Light oj-1259 - Goldbach`s Conjecture

                                                                                    1259 - Goldbach`s Co ...

  8. Goldbach`s Conjecture(LightOJ - 1259)【简单数论】【筛法】

    Goldbach`s Conjecture(LightOJ - 1259)[简单数论][筛法] 标签: 入门讲座题解 数论 题目描述 Goldbach's conjecture is one of t ...

  9. Goldbach’s Conjecture(信息学奥赛一本通 1622)

    [题目描述] 原题来自:Ulm Local,题面详见:POJ 2262 哥德巴赫猜想:任何大于 44 的偶数都可以拆成两个奇素数之和. 比如: 8=3+5 20=3+17=7+13 42=5+37=1 ...

随机推荐

  1. <%@ include file=""%>与<jsp:include page=""/>区别

    jsp页面是把include指令元素(<%@ include file=""%>)所指定的页面的实际内容(也就是代码段)加入到引入它的jsp页面中,合成一个文件后被js ...

  2. centos 6.5 安装 nginx+php+mysql

    一.准备工作 (1)配置防火墙 1.首先检查iptables服务的状态 [root@woxplife ~]# service iptables status iptables: Firewall is ...

  3. org.springframework.dao.EmptyResultDataAccessException

    public Wcrash getWcrashInfo(int id) { String sql = "select plateform_id,android_version,app_ver ...

  4. Mysql bigint 类型转为datetime

    最近在使用quartz,在mysql中其数据库表中的时间都是使用bigint类型存储的,要想使其查询结果显示为yyyy-mm-dd hh:MM:ss的格式需要使用 from_unixtime()函数, ...

  5. 处理事件的方式:两种类的覆盖处理(自己管理,覆盖专用事件函数;自己统一管理,覆盖QWidget::Event通用函数),一种对象的处理(父控件统一管理,即安装过滤器),两种全局处理(QCoreApplication安装过滤器;覆盖notify方法)

    虽然只有一句话,但却是我自己的心得. 特别注意,bool QCoreApplication::notify(QObject *receiver, QEvent *event) 明确指明了要发送的对象, ...

  6. WPF笔记(1.9 样式和控件模板)——Hello,WPF!

    原文:WPF笔记(1.9 样式和控件模板)--Hello,WPF! 资源的另一个用途是样式设置: <Window >  <Window.Resources>    <St ...

  7. 【Xamarin挖墙脚系列:开始使用Xamari4.0系列产品开发IOS】

    一直沉默在Xamarin3.0系列版本上,升级到4.0之后,感觉有些变化.还得适应下. 1 build.host  代理消失了,成了SSH客户端登录.所以,Mac设备需要打开运行远程登录. 2 在Wi ...

  8. error: ‘shared_ptr’ in namespace ‘std’ does not name a type

    用G++编译项目的时候发生标题上的错误,原因是,这是c++ 11标准的.在给g++传递命令行的时候加上-std=c++0x就行了. 还需要在源码中#include<memory> 我的cm ...

  9. You don't seem to have 'make' or 'gmake' in your PATH

    标题尚的错误,不是原因,因为which make的时候是有显示/usr/bin/make的,echo $PATH的时候也是有make的路径的. 编译Qt  ./configure的时候出现标题上错误, ...

  10. HDU5137 How Many Maos Does the Guanxi Worth(枚举+dijkstra)

    How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/5 ...