题目链接:http://ac.jobdu.com/problem.php?pid=1440

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

参考代码:

//
// 1440 Goldbach's Conjecture.cpp
// Jobdu
//
// Created by PengFei_Zheng on 12/04/2017.
// Copyright © 2017 PengFei_Zheng. All rights reserved.
// #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath> using namespace std; bool isPrime(long long n){// here n is no less than 4, so we don't need to consider 2、3
long long x = sqrt(n)+;
for(long long i = ; i <= x ; i ++){
if( == n % i) return false;
}
return true;
} long long n; int main(){
while(scanf("%lld",&n)!=EOF && n!=){
int counter = ;
// beacuse n is even, so 2 can never being included
// in order to reduce the calculation numbers, just need to reverse to n/2
// therefore start with 3 and i+=2
for(int i = ; i <= n/ ; i+=){
if(isPrime(i) && isPrime(n-i)){
counter++;
}
}
printf("%d\n",counter);
}
return ;
}
/**************************************************************
Problem: 1440
User: zpfbuaa
Language: C++
Result: Accepted
Time:40 ms
Memory:1532 kb
****************************************************************/

题目1440:Goldbach's Conjecture(哥达巴赫猜想)的更多相关文章

  1. 1968: C/C++经典程序训练6---歌德巴赫猜想的证明

    1968: C/C++经典程序训练6---歌德巴赫猜想的证明 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 1165  Solved: 499[Submi ...

  2. poj-2909-哥德巴赫猜想

    Description For any even number n greater than or equal to 4, there exists at least one pair of prim ...

  3. 问题 C: Goldbach's Conjecture

    题目描述 Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least ...

  4. Goldbach`s Conjecture(LightOJ - 1259)【简单数论】【筛法】

    Goldbach`s Conjecture(LightOJ - 1259)[简单数论][筛法] 标签: 入门讲座题解 数论 题目描述 Goldbach's conjecture is one of t ...

  5. UVa 543 - Goldbach's Conjecture

    题目大意:给一个偶数,判断是否是两个素数的和. 先用sieve方法生成一个素数表,然后再进行判断即可. #include <cstdio> #include <vector> ...

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

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

  7. F - Goldbach`s Conjecture 对一个大于2的偶数n,找有多少种方法使两个素数的和为n;保证素数a<=b; a+b==n; a,b都为素数。

    /** 题目:F - Goldbach`s Conjecture 链接:https://vjudge.net/contest/154246#problem/F 题意:对一个大于2的偶数n,找有多少种方 ...

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

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

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

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

随机推荐

  1. MySql:charset和collation的设置

    From: http://www.2cto.com/database/201302/189920.html MySql:charset和collation的设置   charset 和 collati ...

  2. 两台linux服务器之间实现挂载

    https://blog.csdn.net/lpp_dd/article/details/78743862 两台linux服务器之间实现挂载: 服务端: 1.首先需要在主机上设置允许挂载的目录 (1) ...

  3. linux 系统安装mysql (rpm)

    其实按照本文安装成功,但是启动依然有问题:最好参考链接配置. http://blog.csdn.net/xiaoxiaoxuewen/article/details/7550107 我用的是ubunt ...

  4. C++入门学习

    使用cout和cin,需要包括C++提供的输入输出库.#include <iostream>    标准输入输出头文件 <string>        using namesp ...

  5. 基于PHP采集数据入库程序(二)

    在上篇基于PHP采集数据入库程序(一) 中提到采集新闻信息页的列表数据,接下来讲讲关于采集新闻具体内容 这是上篇博客的最终数据表截图: 接下来要做的操作就是从数据库中读取所需要采集的URL,进行页面抓 ...

  6. 【WP8】MultiBinding

    WP中系统没有像WPF中直接支持MultiBinding,可以通过以下代码实现 五个类 public class BindingCollection : Collection<BindingBa ...

  7. Xcode 6 免证书真机调试

    前景:在 iOS 开发中,如果想进行真机调试,普遍情况是掏钱,掏钱的情况有两种: 第一种就是:直接在 Apple 官网注册为 Developer,每年99美元:当然这种作为个人开发者的话,是很有必要的 ...

  8. Ubuntu18.10安装网易云音乐(图文并茂!)

    听音乐,怎么少得了网易云音乐,下面我们在Ubuntu18.10上来安装下: 首先进入网易云音乐的下载页:https://music.163.com/#/download,选择下载Ubuntu版本: 我 ...

  9. .NET工具集合

    工具 (1) 代码分析 .NET Memory Profiler - http://memprofiler.com/ANTS Profiler - http://www.red-gate.com/co ...

  10. SQL Compare数据库比较工具 完全破解+使用教程

    来源http://www.cnblogs.com/duci/articles/4482665.html 一.使用教程 SQL Compare是编程人员常用的比较两个数据库之间差异的工具.可以用来比较数 ...