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>=6,问把n分成两个奇质数之和有几种方案

直接暴力枚举其中一个是啥,只要不重复统计就行

 #include<cstdio>
#include<iostream>
#include<cstring>
#define LL long long
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
LL n;
bool mk[];
int p[],len;
inline void getp()
{
for (int i=;i<=;i++)
{
if (!mk[i])
{
p[++len]=i;
for (int j=*i;j<=;j+=i)mk[j]=;
}
}
}
int main()
{
getp();
while (~scanf("%lld",&n)&&n)
{
int ans=;
for (int i=;p[i]*<=n;i++)
if (!mk[n-p[i]])ans++;
printf("%d\n",ans);
}
}

poj 2909

[暑假集训--数论]poj2909 Goldbach's Conjecture的更多相关文章

  1. [暑假集训--数论]poj2262 Goldbach's Conjecture

    In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in whic ...

  2. [暑假集训--数论]hdu2136 Largest prime factor

    Everybody knows any number can be combined by the prime number. Now, your task is telling me what po ...

  3. [暑假集训--数论]hdu1019 Least Common Multiple

    The least common multiple (LCM) of a set of positive integers is the smallest positive integer which ...

  4. [暑假集训--数论]poj2115 C Looooops

    A Compiler Mystery: We are given a C-language style for loop of type for (variable = A; variable != ...

  5. [暑假集训--数论]poj1365 Prime Land

    Everybody in the Prime Land is using a prime base number system. In this system, each positive integ ...

  6. [暑假集训--数论]poj2034 Anti-prime Sequences

    Given a sequence of consecutive integers n,n+1,n+2,...,m, an anti-prime sequence is a rearrangement ...

  7. [暑假集训--数论]poj1595 Prime Cuts

    A prime number is a counting number (1, 2, 3, ...) that is evenly divisible only by 1 and itself. In ...

  8. [暑假集训--数论]poj3518 Prime Gap

    The sequence of n − 1 consecutive composite numbers (positive integers that are not prime and not eq ...

  9. [暑假集训--数论]poj1730 Perfect Pth Powers

    We say that x is a perfect square if, for some integer b, x = b 2. Similarly, x is a perfect cube if ...

随机推荐

  1. python 读取mat文件

    import osimport scipy.io as sio import numpy as np #matlab文件名 matfn='/home/user/devkit/data/meta_det ...

  2. axios向后端请求解决跨域问题

    我要向后端的请求的url是 http://192.168.3.25/ productInfo/insert 我是先用niginx转成localhost:8081 找conf/ nginx.conf , ...

  3. Java十进制转成二进制 八进制 十六进制

    int a = 357;//十进制转成二进制System.out.println(Integer.toBinaryString(a)); package com.swift; import java. ...

  4. C的xml编程-libxml2

    这里主要讲述libxml2在linux下的使用. (以下内容除了linux下的安装步骤是自己写的,其余均出自http://www.blogjava.net/wxb_nudt/archive/2007/ ...

  5. Vue3.0脚手架搭建

    https://www.jianshu.com/p/fbcad30031c2 vue3.0官网:https://cli.vuejs.org/zh/guide/ 介绍: notice: 这份文档是对应 ...

  6. JS - OOP-继承的最佳实现方式

    如上图,使用第三种方式实现继承最好,也就是加了下划线的. 但是Object.create方法是ES6才支持的,所以,右边就写了一个实现其同样功能的函数.

  7. day 71 Django基础六之ORM中的锁和事务

    Django基础六之ORM中的锁和事务   本节目录 一 锁 二 事务 三 xxx 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 锁 行级锁 select_for_update(no ...

  8. stm32之PWM博客好文收藏

    https://www.cnblogs.com/jiwangbujiu/p/5616376.html STM32F103 使用TIM3产生四路PWM https://www.cnblogs.com/c ...

  9. 动态规划:HDU-2542-0-1背包问题:饭卡

    解题心得: 这题就是一个简单的0-1背包问题,只不过加了一系列的限制.可以想办法消去限制,直接转换成0-1背包问题的模板形式. 需要注意的几个点:首先对于剩余的5元钱的处理可以直接在总的钱数上将5减去 ...

  10. 图学java基础篇之并发

    概述 并发处理本身就是编程开发重点之一,同时内容也很繁杂,从底层指令处理到上层应用开发都要涉及,也是最容易出问题的地方.这块知识也是评价一个开发人员水平的重要指标,本人自认为现在也只是学其皮毛,因此本 ...