博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
F - Goldbach`s Conjecture LightOJ - 1259(素数筛)
阅读量:4557 次
发布时间:2019-06-08

本文共 1519 字,大约阅读时间需要 5 分钟。

F - Goldbach`s Conjecture LightOJ - 1259

题目链接:

题目:

Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:

Every even integer, greater than 2, can be expressed as the sum of two primes [1].

Now your task is to check whether this conjecture holds for integers up to 107.

Input

Input starts with an integer T (≤ 300), denoting the number of test cases.

Each case starts with a line containing an integer n (4 ≤ n ≤ 107, n is even).

Output

For each case, print the case number and the number of ways you can express n as sum of two primes. To be more specific, we want to find the number of (a, b) where

1)      Both a and b are prime

2)      a + b = n

3)      a ≤ b

Sample Input

2

6

4

Sample Output

Case 1: 1

Case 2: 1

Note
    1. An integer is said to be prime, if it is divisible by exactly two different integers. First few primes are 2, 3, 5, 7, 11, 13, ...
题意:给你一个偶数,算出多少种a+b=n的可能,其中a,b要是素数且a<b
思路;素数筛,打表,
//// Created by hanyu on 2019/8/12.//#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;const int maxn=1e7+5;using namespace std;bool isprime[maxn];int prime[maxn/10],pos;void getp(){ pos=0; memset(isprime,false,sizeof(isprime)); isprime[0]=isprime[1]=true; for(long long i=2;i

 

注意数据范围,我re了很多次。。。。

转载于:https://www.cnblogs.com/Vampire6/p/11341452.html

你可能感兴趣的文章
POJ训练计划3080_Blue Jeans(串处理/暴力)
查看>>
python3.x 与 python2.x 差别记录
查看>>
HTML DOM 节点
查看>>
静态代码块 和 构造代码块
查看>>
生成随机验证码
查看>>
font-family,font-size,color
查看>>
平安夜和圣诞节
查看>>
Search Insert Position
查看>>
数据可视化(5)--jqplot经典实例
查看>>
u盘复制提示文件过大
查看>>
grails项目数据源配置
查看>>
mysql数据库索引简单原理
查看>>
【爱笑话7.0版】笑话两万篇,免费阅读,绝无广告
查看>>
The square chest
查看>>
不用第三个变量实现a,b的值交换
查看>>
四则运算
查看>>
为VS2010默认模板添加版权信息(转)
查看>>
int类型属性判空
查看>>
remote: ERROR: missing Change-Id in commit message footer
查看>>
js中的事件总结
查看>>