poj2262 Goldbach's Conjecture

欧拉筛把素数筛出来,再枚举一下。

#include<iostream>
#include<cstdio>
#include<cstring>
#define re register
using namespace std;
#define N 1000001
int n,v[N],pri[N],cct; bool is[N];
int main(){
for(int i=;i<N;++i){
if(!v[i]) is[v[i]=pri[++cct]=i]=;
for(int j=;j<=cct;++j){
if(pri[j]>i||pri[j]*i>=N) break;
v[pri[j]*i]=pri[j];
}
}
while(scanf("%d",&n)){
if(!n) return ;
bool flag=;
for(int i=;i<=cct&&flag;++i)
if(is[i]&&is[n-i])
printf("%d = %d + %d\n",n,i,n-i),flag=;
if(flag) puts("Goldbach's conjecture is wrong.");
}return ;
}

poj2262 Goldbach's Conjecture的更多相关文章

  1. [POJ2262] Goldbach’s Conjecture

    Goldbach's Conjecture Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 48161   Accepted: ...

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

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

  3. poj2262 Goldbach's Conjecture——筛素数

    题目:http://poj.org/problem?id=2262 水水更健康~ 代码如下: #include<iostream> #include<cstdio> #incl ...

  4. POJ 2262 Goldbach's Conjecture (打表)

    题目链接: https://cn.vjudge.net/problem/POJ-2262 题目描述: In 1742, Christian Goldbach, a German amateur mat ...

  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. sql语句如何删除最后一条和第一条信息

    这是先前建好的SQL数据库中的test表, sql语句: delete a from test a,(select max(id) id from test) b where a.id = b.id ...

  2. cocos2dx游戏--欢欢英雄传说--添加动作

    添加完人物之后接着给人物添加上动作.我们为hero添加4个动作:attack(由3张图片构成),walk(由2张图片构成),hit(由1张图片构成),dead(由1张图片构成):同样,为enemy添加 ...

  3. EL表达式各种函数使用大全

      引入<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ...

  4. 《IT项目经理成长手记》

    下载地址: https://download.csdn.net/download/h623691640/9109265 读后感: 曾担任过试用期3个月项目经理,遇到的问题确实如书中所说,几乎有一些是一 ...

  5. iOS 如何在视图中添加一个用xib创建的view

    NSArray *nib = [[NSBundle mainBundle]loadNibNamed:[pages objectAtIndex:] owner:self options:nil]; // ...

  6. 170519、FastDFS分布式文件系统的安装与使用(单节点)

    基于 于 D Do ubbo 的分布 式系统架构 视频 教程 高 级篇S FastDFS 分布 式 文件系统的安装与使用 (单 节点)跟踪 服务器 : 192.168.4.12 21 1 (edu- ...

  7. CH1602 The XOR Largest Pair【Trie树】

    1602 The XOR Largest Pair 0x10「基本数据结构」例题 描述 在给定的N个整数A1,A2……AN中选出两个进行xor运算,得到的结果最大是多少? 输入格式 第一行一个整数N, ...

  8. hihoCoder_1449_后缀自动机三·重复旋律6

    #1449 : 后缀自动机三·重复旋律6 时间限制:15000ms 单点时限:3000ms 内存限制:512MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为一段数构成的数 ...

  9. 利用Python进行端口扫描

    利用Python进行端口扫描 - Dahlhin - 博客园 https://www.cnblogs.com/dachenzi/p/8676104.html Python实现对一个网络段扫描及端口扫描 ...

  10. TA-Lib中文文档(二):talib安装

    安装 使用pip安装 PyPI: $ pip install TA-Lib Or checkout the sources and run setup.py yourself: $ python se ...