素数判定...很简单= =.....只是因为训练题有,所以顺便更~

 #include<cstdio>
#include<memory.h>
#define maxn 5000005
int prime[maxn];
void f()
{
memset(prime,,sizeof(prime));
prime[] = prime[] = ;
for(int i = ; i < maxn; i++)
{
if(!prime[i])
{
for(int j = * i; j < maxn; j += i)
prime[j] = ;
}
}
}
int main()
{
freopen("input.txt","r",stdin);
int n,i;
f();
while(scanf("%d",&n) && n)
{
for(i = ; i < n /; i += )
{
if(!prime[i] && !prime[n - i])
break;
}
printf("%d = %d + %d\n",n,i,n-i);
}
return ;
}

poj 2262 Goldbach's Conjecture的更多相关文章

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

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

  2. poj 2262 Goldbach's Conjecture——筛质数(水!)

    题目:http://poj.org/problem?id=2262 大水题的筛质数. #include<iostream> #include<cstdio> #include& ...

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

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

  4. POJ 2262 Goldbach's Conjecture 数学常识 难度:0

    题目链接:http://poj.org/problem?id=2262 哥德巴赫猜想肯定是正确的 思路: 筛出n范围内的所有奇质数,对每组数据试过一遍即可, 为满足b-a取最大,a取最小 时空复杂度分 ...

  5. POJ 2262 Goldbach's Conjecture(Eratosthenes筛法)

    http://poj.org/problem?id=2262 题意: 哥德巴赫猜想,把一个数用两个奇素数表示出来. 思路:先用Eratosthenes筛法打个素数表,之后枚举即可. #include& ...

  6. POJ 2262 Goldbach&#39;s Conjecture(素数相关)

    POJ 2262 Goldbach's Conjecture(素数相关) http://poj.org/problem?id=2262 题意: 给你一个[6,1000000]范围内的偶数,要你将它表示 ...

  7. Poj 2262 / OpenJudge 2262 Goldbach's Conjecture

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

  8. Poj 2662,2909 Goldbach's Conjecture (素数判定)

    一.Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard ...

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

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

随机推荐

  1. PHP图片处理库Grafika详细教程

    转载自51CTO 开发频道 1.图像基本处理:http://developer.51cto.com/art/201611/520928.htm 2.图像特效处理模块:http://developer. ...

  2. 买茶叶想到的哪个比较便宜 x1/y1 >x2/y2 x代表多少钱 y代表 多少克 无聊的试炼

    茶叶1 128元     200克 茶叶2  330元    160克 当然这个哪个便宜 一眼就知道了,这里不过抛砖引玉 128元    330元 200克    160克 我们把价钱用x表示 多少克 ...

  3. MS SQMServer2008R2 连接不到远程服务的解决办法

    问题: MS SQMServer2008R2 连接不到远程服务的解决办法.程序提示的错误如下: [2017/02/19 17:46:21] 在与 SQL Server 建立连接时出现与网络相关的或特定 ...

  4. python 函数调用顺序

    def foo(): print ('in the foo') bar() def bar(): print ('in the bar') foo() 1.foo函数进入内存 2.bar函数进入内存 ...

  5. Flex 排序 SortField and Sort

    部分代码 var arrayOfCat:ArrayCollection=outerDocument.getCagegory();   // 需要排序的数组 //创建SortField对象 var so ...

  6. spring学习 四 对象的创建

    spring中,有三种创建对象的方式 (1)构造创建 (2)实例工厂构造 (3)静态工厂构造 一  构造器创建 在构造器创建对象时,有无参构造和有参构造 两种 (1)在spring中,默认的是无参构造 ...

  7. python之面向对象篇6

    一.继承与派生 什么是继承 继承一种新建类的方式,新建的类称为子类或者派生类,被继承的类称为父类或基类或超类 子类会遗传父类的一系列属性 python支持多继承 注意: 在python3中,如果没有显 ...

  8. Spring MVC和Struts2的比较[转]

    虽然说没有系统的学习过Spring MVC框架, 但是工作这么长时间, 基本上在WEB层使用的都是Spring MVC, 自己觉得Struts2也是一个不错的WEB层框架, 这两种框架至今自己还未有比 ...

  9. MySQL批量修改表前缀

    error_reporting(0); $old_pre = 'tdr_'; // 原表前缀 $new_pre = 'db_'; // 新表前缀 // 配置连接 $db = new mysqli('1 ...

  10. bootstrap 后台模板

    http://wangye0119-html1.demo.smallseashell.com/index.html