题面

T组询问,每组询问是一个偶数n

验证哥德巴赫猜想

回答n=a+b

且a,b(a<=b)是质数的方案个数

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).

Sol

垃圾题,枚举质数就好

# include <bits/stdc++.h>
# define RG register
# define IL inline
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int __(1e7 + 10); IL ll Read(){
char c = '%'; ll x = 0, z = 1;
for(; c > '9' || c < '0'; c = getchar()) if(c == '-') z = -1;
for(; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
return x * z;
} int prime[__ / 10], num, n, ans;
bool isprime[__]; IL void Prepare(){
isprime[1] = 1;
for(RG int i = 2; i <= __; ++i){
if(!isprime[i]) prime[++num] = i;
for(RG int j = 1; j <= num && i * prime[j] <= __; ++j){
isprime[i * prime[j]] = 1;
if(!(i % prime[j])) break;
}
}
} int main(RG int argc, RG char *argv[]){
Prepare();
for(RG int T = Read(), Case = 1; Case <= T; ++Case){
n = Read(); ans = 0;
for(RG int i = 1; i <= num && prime[i] + prime[i] <= n; ++i) ans += !isprime[n - prime[i]];
printf("Case %d: %d\n", Case, ans);
}
return 0;
}

LightOJ1259 Goldbach`s Conjecture的更多相关文章

  1. LightOJ1259 Goldbach`s Conjecture —— 素数表

    题目链接:https://vjudge.net/problem/LightOJ-1259 1259 - Goldbach`s Conjecture    PDF (English) Statistic ...

  2. LightOJ-1259 Goldbach`s Conjecture 数论 素数筛

    题目链接:https://cn.vjudge.net/problem/LightOJ-1259 题意 给一个整数n,问有多少对素数a和b,使得a+b=n 思路 素数筛 埃氏筛O(nloglogn),这 ...

  3. 【LightOJ1259】Goldbach`s Conjecture(数论)

    [LightOJ1259]Goldbach`s Conjecture(数论) 题面 Vjudge T组询问,每组询问是一个偶数n 验证哥德巴赫猜想 回答n=a+b 且a,b(a<=b)是质数的方 ...

  4. LightOJ - 1259 - Goldbach`s Conjecture(整数分解定理)

    链接: https://vjudge.net/problem/LightOJ-1259 题意: Goldbach's conjecture is one of the oldest unsolved ...

  5. Goldbach's Conjecture

     Goldbach's Conjecture Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I ...

  6. Poj 2262 / OpenJudge 2262 Goldbach's Conjecture

    1.Link: http://poj.org/problem?id=2262 http://bailian.openjudge.cn/practice/2262 2.Content: Goldbach ...

  7. poj 2262 Goldbach's Conjecture(素数筛选法)

    http://poj.org/problem?id=2262 Goldbach's Conjecture Time Limit: 1000MS   Memory Limit: 65536K Total ...

  8. HDOJ 1397 Goldbach's Conjecture(快速筛选素数法)

    Problem Description Goldbach's Conjecture: For any even number n greater than or equal to 4, there e ...

  9. Goldbach's Conjecture(哥德巴赫猜想)

    Goldbach's Conjecture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

随机推荐

  1. 在阿里云CentOS 7创建swap分区

    https://blog.tanteng.me/2016/03/aliyun-centos-7-swap/ Centos 系统swap虚拟内存添加与删除配置

  2. 原生js总结(干货)

    1.js基本数据类型 number string boolean underfined null 2.查找文档中的特定元素 document.getElementById("id" ...

  3. ajaxfileupload批量上传文件+图片尺寸限制

    1.首先展示ajaxfileupload代码,在这里修改为批量上传 //ajaxfileupload不展示全部代码,这是修改前与修改后代码对比,目的是上传多个文件 createUploadForm: ...

  4. 机器学习03:K近邻算法

    本文来自同步博客. P.S. 不知道怎么显示数学公式以及排版文章.所以如果觉得文章下面格式乱的话请自行跳转到上述链接.后续我将不再对数学公式进行截图,毕竟行内公式截图的话排版会很乱.看原博客地址会有更 ...

  5. Pycharm常用的使用方法

    PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如调试.语法高亮.Project管理.代码跳转.智能提示.自动完成.单元测试.版本控制. ...

  6. [原创]CentOS7安装远程工具teamviewer12

    系统环境:CentOS 7.0.1 1.下载安装# wget https://dl.tvcdn.de/download/version_12x/teamviewer_12.0.85001.i686.r ...

  7. Git 上传 GitHub

    1.下载 2.安装 3.功能识别 3-1.查看git版本  git  --version 3-2.移除原来的版本 yum  remove git 4.配置 4-1.用户配置信息 git config ...

  8. 标准Http协议的六种请求方法详解

    标准Http协议支持六种请求方法,即: 1.GET 2.POST 3.PUT 4.Delete 5.HEAD 6.Options 但其实我们大部分情况下只用到了GET和POST.如果想设计一个符合RE ...

  9. Windows下nexus-3.*搭建Maven私服

    1.下载 从官网下载https://help.sonatype.com/display/NXRM3/Download 选择Windows archive https://download.sonaty ...

  10. Node.js,commonjs,require

    环境: Node应用由模块组成,采用CommonJS模块规范. node的全局对象是global,没有window这个对象. process表示当前执行的进程,挂在global之下. CommonJS ...