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. 异常处理与调试4 - 零基础入门学习Delphi53

    调试(Debug) 让编程改变世界 Change the world by program 调试(Debug) 在应用程序开发中检测.处理程序中的错误是一个非常重要的环节.在Delphi的集成开发环境 ...

  2. Js函数加括号、不加括号(转)

    函数只要是要调用它进行执行的,都必须加括号.此时,函数()实际上等于函数的返回值.当然,有些没有返回值,但已经执行了函数体内的行为,这个是根本,就是说,只要加括号的,就代表将会执行函数体代码. 不加括 ...

  3. org.springframework.dao.EmptyResultDataAccessException

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

  4. DataTable Select 使用

    DataView dv = new DataView(table); dv.RowFilter = " Type='10' and Visible='true'"; dv.Sort ...

  5. DOSUSB 2.0 免费版的限制原理

    两年前,我在写USB的文章时,多次提到了DOSUSB这个东东,这两年也没有关注这方面的变化,最近,有机会重新进入DOSUSB的官方网站(www.dosusb.net),欣喜地发现,这个网站不仅依然存在 ...

  6. 杀死MySQL的连接

    命令  kill 执行线程号 C# 执行杀死指定的连接 1  强制Kill掉 internal protected void KillConnection(MySqlConnection c) { i ...

  7. C语言的本质(31)——C语言与汇编之函数调用的本质

    我们一段代码来研究函数调用的过程.首先我们写一段简单的小程序: int sum(int c, int d) { inte = c + d; returne; } int func(int a, int ...

  8. 在非MFC的win 32程序里面能够使用CString类

    论坛有会员用到了.,今天给大家说说CSring如何在非mfc下的调用第一:先要包含 #include "afx.h" 包含之后会报windows.h重复定义我们需要把这个头文件包含 ...

  9. 使用fdisk进行磁盘管理

    http://itercast.com/lecture/17 disk是来自IBM的老牌分区软件,几乎所有Linux系统均默认安装 fdisk是一个MBR分区工具,不可用于GPT分区 只有超级用户(r ...

  10. hdu 5631 Rikka with Graph(图)

    n个点最少要n-1条边才能连通,可以删除一条边,最多删除2条边,然后枚举删除的1条边或2条边,用并查集判断是否连通,时间复杂度为O(n^3) 这边犯了个错误, for(int i=0;i<N;i ...