Description

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. There can be many such numbers. 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 215. 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
题目大意:

对于任何偶数n大于等于4,至少存在一个质数p1和p2这样

n = p1和p2

这个猜想尚未证明也不拒绝。没人知道是否这个猜想成立。然而,人们可以发现这样一双质数,如果有的话,对于给定的一个偶数。这里的问题是编写一个程序,报告所有成对的质数的数量满足条件给定的一个偶数的猜想。

给出一个偶数序列作为输入。可以有许多这样的数字。对应于每个数字,程序应该输出对上面提到的数量。注意,我们感兴趣的数量对本质上是不同的,因此你不应计数(p1,p2)和(p2,p1)分别作为两个不同的配对。

#include<iostream>
using namespace std;
bool aa(int b) //判断质数函数
{
for(int i=3;i*i<=b;i++)
{
if(b%i==0)return 0;
}
return 1;
} int main()
{
int a;
cin>>a;
while(a)
{
int q=0;
for(int j=3;j*2<=a;j+=2)//排除偶数,减少时间消耗
{
if(aa(j)&&aa(a-j))
q++;
}
cout<<q<<endl;
cin>>a;
} return 0;
}

  

poj-2909-哥德巴赫猜想的更多相关文章

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

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

  2. *CF2.D(哥德巴赫猜想)

    D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  3. C#实现哥德巴赫猜想

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Goet ...

  4. code forces 382 D Taxes(数论--哥德巴赫猜想)

    Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...

  5. CF735D Taxes 哥德巴赫猜想\判定素数 \进一步猜想

    http://codeforces.com/problemset/problem/735/D 题意是..一个数n的贡献是它的最大的因子,这个因子不能等于它本身 然后呢..现在我们可以将n拆成任意个数的 ...

  6. Codeforces Round #382 (Div. 2) D. Taxes 哥德巴赫猜想

    D. Taxes 题目链接 http://codeforces.com/contest/735/problem/D 题面 Mr. Funt now lives in a country with a ...

  7. Codeforces 735D:Taxes(哥德巴赫猜想)

    http://codeforces.com/problemset/problem/735/D 题意:给出一个n,这个n可以分解成 n = n1 + n2 + -- + nk,其中k可以取任意数.要使得 ...

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

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

  9. Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想

    D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  10. 哥德巴赫猜想证明(C语言实现50以内的正偶数证明)

    <一>哥德巴赫猜想内容: 一个充分大的偶数(大于或等于6)可以分解为两个素数之和. <二>实现要点: 要点: 判断素数(质数):除了1和本身没有其他约数. 最小的质数:2 判断 ...

随机推荐

  1. SpringMVC的常用注解

             在SpringMVC中常用的注解主要都是用于Controller上,所以下面的四大不同类型的注解都是根据它们处理的request的不同内容部分来区分的:         处理requ ...

  2. 简述在javascript和jquery中cookie的使用

    html <body onload="cookieJar()"></body> javascript <script href="../st ...

  3. 2_成员函数(Member Functions)

    成员函数以定从属于类,不能独立存在,这是它与普通函数的重要区别.所以我们在类定义体外定义成员函数的时候,必须在函数名之前冠以类名,如Date::isLeapYear().但如果在类定义体内定义成员函数 ...

  4. AndFix

    AndFix 是阿里巴巴开源的 Android 应用热修复工具,帮助 Anroid 开发者修复应用的线上问题.Andfix 是 "Android hot-fix" 的缩写.支持 A ...

  5. 1.4 PCI总线的中断机制

    PCI总线使用INTA#.INTB#.INTC#和INTD#信号向处理器发出中断请求.这些中断请求信号为低电平有效,并与处理器的中断控制器连接.在PCI体系结构中,这些中断信号属于边带信号(Sideb ...

  6. Android Gradle项目Hotfix热修复技术的接入

    https://github.com/AItsuki/HotFix Issues MAC系统无法自动打包补丁,原因可能是路径分隔符问题 使用谷歌multidex分包后无法注入代码(开启multidex ...

  7. stm32开发之使用Keil MDK以及标准外设库创建STM32工程

    ‑6 MDK详细版本信息 ‑8保存路径的选择 ‑9选择芯片型号 ‑10拷贝启动代码选择 ‑11选择 Manage Comoonents ‑12编辑组并添加对应文件 ‑13工程管理文件列表 ‑14选择进 ...

  8. PL/SQL NOCOPY限制模式

    NOCOPY模式用于限定OUT模式和IN OUT模式在调用时是不是以传引用的方式进行. 默认情况下,OUT模式和IN OUT模式的参数是以传值的方式进行调用的. IN模式总是以传引用的方式,如果用NO ...

  9. MongoDB远程维护客户端工具的使用!

    MongoDB在互联网项目中使用越来越多,布署在云端Linux服务器上的mongoDB数据库,大多存在远程维护不便的问题,开放27017端口又将导致安全隐患.有个折中的办法就是使用基于web的客户端管 ...

  10. Python Cookbook(第3版)中文版:15.21 诊断分段错误

    15.21 诊断分段错误¶ 问题¶ 解释器因为某个分段错误.总线错误.访问越界或其他致命错误而突然间奔溃. 你想获得Python堆栈信息,从而找出在发生错误的时候你的程序运行点. 解决方案¶ faul ...