简单题

 #include <iostream>
 #include <stdio.h>
 #include <string>
 #include <stack>
 #include <map>
 #include <vector>
 #include <algorithm>
 using namespace std;

 bool isPrime(int n) {
     ) return true;
      ==  || n == ) return false;
     ; i*i <= n; ++i) {
         ) return false;
     }
     return true;
 }

 int main()
 {
     int N;
     while (cin >> N && N) {
         bool flag = false;
         ; i <= N/; i+=) {
             if (isPrime(i) && isPrime(N-i)) {
                 flag = true;
                 cout << N << " = " << i << " + " << N-i << endl;
                 break;
             }
         }
         if (!flag) cout << "Goldbach's conjecture is wrong." << endl;
     }

     ;
 }

poj: 2262的更多相关文章

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

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

  2. POJ中和质数相关的三个例题(POJ 2262、POJ 2739、POJ 3006)

    质数(prime number)又称素数,有无限个.一个大于1的自然数,除了1和它本身外,不能被其他自然数整除,换句话说就是该数除了1和它本身以外不再有其他的因数:否则称为合数.      最小的质数 ...

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

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

  4. Poj 2262 / OpenJudge 2262 Goldbach's Conjecture

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

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

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

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

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

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

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

  8. poj 2262【素数表的应用---判断素数】【哈希】

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

  9. Goldbach's Conjecture POJ - 2262 线性欧拉筛水题 哥德巴赫猜想

    题意 哥德巴赫猜想:任一大于2的数都可以分为两个质数之和 给一个n 分成两个质数之和 线行筛打表即可 可以拿一个数组当桶标记一下a[i]  i这个数是不是素数  在线性筛后面加个装桶循环即可 #inc ...

随机推荐

  1. 策略模式代替大量的if else

    原代码 public class Example { public Double calRecharge(Double charge, RechargeTypeEnum type) { if (typ ...

  2. java类加载过程

    类(型)的生命周期--装载.连接.初始化.卸载 Java虚拟机通过装载.连接和初始化一个Java类型,使该类型可以被正在运行的Java程序所使用. 1.       装载 装载阶段包括三个基本动作: ...

  3. GLFW is an Open Source, multi-platform library for OpenGL

    http://www.glfw.org/ http://download.csdn.net/user/hengyishu

  4. Github简明教程(转)

    原文地址 : http://wuyuans.com/2012/05/github-simple-tutorial/ github是一个基于git的代码托管平台,付费用户可以建私人仓库,我们一般的免费用 ...

  5. JavaScript正则表达式(三)

    正则表达式可以: •测试字符串的某个模式.例如,可以对一个输入字符串进行测试,看在该字符串是否存在一个电话号码模式或一个信用卡号码模式.这称为数据有效性验证 •替换文本.可以在文档中使用一个正则表达式 ...

  6. 20145211 《Java程序设计》第3周学习总结——绝知此事要躬行

    教材学习内容总结 4.1何为面向对象 面向对象,面向过程都是一种思想,没有高低之分.面向对象,就像是对冰箱操作,冰箱是一个介质,用法就像是c语言中的结构体,功能定义在对象上.面向对象,角色转变,让我们 ...

  7. mongoDB安装学习

    一: 下载安装 上MongoDB官网 ,下载之后安装 安装好了之后在对应的安装目录下就会看到安装的文件 二:启动 微软徽标+R,输入cmd,首先找到“mongodb”的路径,然后运行mongod开启命 ...

  8. js操作table倒叙显示序号的问题

    今天遇到一奇葩问题,就是在js添加table时,序号是倒叙显示的,而且数据库查出来时正序的,为什么显示是倒叙的呢? 我百度一番,终于有了结果: var newRow=table.insertRow(- ...

  9. 【C++】error C4146: 一元负运算符应用于无符号类型,结果仍为无符号类型

    刷leetcode 263.uglynumber时,代码如下: class Solution { public: bool isUgly(int num) { int temp = num; ) re ...

  10. angularJs:双向数据绑定

    示例1 <!DOCTYPE html> <html ng-app> <head> <meta charset="UTF-8" /> ...