博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lightoj1259——Goldbach`s Conjecture(哥德巴赫猜想)
阅读量:2344 次
发布时间:2019-05-10

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

Description

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

自己的模板总是差那么多内存,换了一个就过了。。。

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f#define MAXN 10000005#define mod 1000000007using namespace std;bool notprime[MAXN];int primes[700005]; //素数从i=1开始void get_prime(){ notprime[1]=true; for(int i=2;i

转载地址:http://hicvb.baihongyu.com/

你可能感兴趣的文章
常用软件下载地址
查看>>
修改spring boot 启动logo
查看>>
spring boot-启动及配置文件
查看>>
HttpsURLConnection 安全传输(HTTPS--Secure Hypertext Transfer Protocol-安全超文本传输协议)...
查看>>
ASP.NET跨页面传值的技巧
查看>>
ASP.NET页面之间传递值解析
查看>>
我要学ASP.NET MVC 3.0(八): MVC 3.0 传递和保存你的Model
查看>>
我要学ASP.NET MVC 3.0(九): MVC 3.0 验证你的Model
查看>>
我要学ASP.NET MVC 3.0(十): MVC 3.0 使用 Forms身份验证
查看>>
我要学ASP.NET MVC 3.0(十一): MVC 3.0 使用筛选器
查看>>
ASP.NET MVC3、Pager 分页
查看>>
在 ASP.NET MVC 中创建自定义 HtmlHelper 控件
查看>>
MSDN---扩展方法 (C# 方法中的this参数)
查看>>
我要学ASP.NET MVC 3.0(十四): MVC 3.0 实例系列之创建数据表格
查看>>
我要学ASP.NET MVC 3.0(十五): MVC 3.0 实例系列之表格的排序
查看>>
我要学ASP.NET MVC 3.0(十七): MVC 3.0 实例之表格中数据的筛选
查看>>
Displaying a Sorted, Paged, and Filtered Grid of Data in ASP.NET MVC
查看>>
C#中的操作符
查看>>
ADO.NET Ling to Sql 语法
查看>>
ASP.NET MVC 2博客系列之一:强类型HTML辅助方法
查看>>