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的更多相关文章
- [POJ2262] Goldbach’s Conjecture
Goldbach's Conjecture Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 48161 Accepted: ...
- [暑假集训--数论]poj2262 Goldbach's Conjecture
In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in whic ...
- poj2262 Goldbach's Conjecture——筛素数
题目:http://poj.org/problem?id=2262 水水更健康~ 代码如下: #include<iostream> #include<cstdio> #incl ...
- POJ 2262 Goldbach's Conjecture (打表)
题目链接: https://cn.vjudge.net/problem/POJ-2262 题目描述: In 1742, Christian Goldbach, a German amateur mat ...
- Goldbach's Conjecture
Goldbach's Conjecture Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I ...
- Poj 2262 / OpenJudge 2262 Goldbach's Conjecture
1.Link: http://poj.org/problem?id=2262 http://bailian.openjudge.cn/practice/2262 2.Content: Goldbach ...
- poj 2262 Goldbach's Conjecture(素数筛选法)
http://poj.org/problem?id=2262 Goldbach's Conjecture Time Limit: 1000MS Memory Limit: 65536K Total ...
- HDOJ 1397 Goldbach's Conjecture(快速筛选素数法)
Problem Description Goldbach's Conjecture: For any even number n greater than or equal to 4, there e ...
- Goldbach's Conjecture(哥德巴赫猜想)
Goldbach's Conjecture Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
随机推荐
- jstl标签怎么实现分页中下一页
<script type="text/javascript"> //分页按钮处理 function goPageAction(page ...
- 《转载》struts旅程《1》
struts简介 Struts是Apache软件基金会(ASF)赞助的一个开源项目.它最初是jakarta项目中的一个子项目,并在2004年3月成为ASF的顶级项目.它通过采用JavaServlet/ ...
- IOS项目分层
上传者:踏浪帅 分类:其他(Others) 查看次数:408 下载次数:70 上传时间:2016-01-07 大小:3 KB 主项目中的分层主要包含四个模块,Main(主要).Expand(扩展).R ...
- Mac环境下搭建PhoneGap环境
首先,官方文档中,要求,编译需要使用Intel架构的 Mac OS X系统的Mac设备,最低要使用XCode4.5以上版本和Mac OS X 10.7以上的系统以及IOS6.0 以上的SDK,至于发布 ...
- 微信小程序 --- model弹框
model弹框:在屏幕中间弹出,让你进行选择: 效果: 代码: <button type="primary" bindtap="btnclick"> ...
- Comparable 与 Comparator的区别
Comparable & Comparator 都是用来实现集合中元素的比较.排序的,只是 Comparable 是在集合内部定义的方法实现的排序,Comparator 是在集合外部实现的排序 ...
- SpringBoot SpringApplication底层源码分析与自动装配
目录 抛出问题 @SpringBootApplication注解剖析 SpringApplication类剖析 第一步:配置SpringBoot Bean来源 第二步 :自动推断SpringBoot的 ...
- 焦作网络赛E-JiuYuanWantstoEat【树链剖分】【线段树】
You ye Jiu yuan is the daughter of the Great GOD Emancipator. And when she becomes an adult, she wil ...
- 解决“The remote certificate is invalid according to the validation procedure”问题
在用HttpClient发起https请求时,遭遇了“The remote certificate is invalid according to the validation procedure”异 ...
- Scanline Fill Algorithm
https://www.sccs.swarthmore.edu/users/02/jill/graphics/hw3/hw3.html http://web.cs.ucdavis.edu/~ma/EC ...