欧拉计划(10)Summation of primes
来源:互联网 发布:阿里云 幕布申请 编辑:程序博客网 时间:2024/05/18 03:46
【题目】
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
【翻译】10以下的质数的和是2 + 3 + 5 + 7 = 17.
找出两百万以下所有质数的和。
【思路】依旧暴力法【代码】
bool isPrime( int value){if(value==2) return true;if(value<2 || (!(value&1)))return false;for(int i=2;i<(int)sqrt(value)+1;i++){if(value%i==0){return false;}}return true;}void test10(){long long int sum=2;for(int i=3;i<2000000;i+=2)if(isPrime(i))sum+=i;cout<<sum<<endl;}
【答案】本题答案为 142913828922。
0 0
- 欧拉计划(10)Summation of primes
- 欧拉项目第十题 Summation of primes
- (Problem 10)Summation of primes
- Problem 10:Summation of primes
- Problem 10:Summation of primes
- PE 10 Summation of primes
- Problem 10 Summation of primes
- 【Project Euler】【Problem 10】Summation of primes
- project euler problem 10:Summation of primes
- projecteuler---->problem=10----Summation of primes
- 10 Summation of primes - Project Euler
- Problem 10 Summation of primes (素数和)
- Project Euler Problem 10: Summation of primes
- project euler 10 Summation of primes
- summation of four primes
- 110705 Summation of Four Primes
- Summation of Four Primes - PC110705
- 10168 Summation of Four Primes
- ListView学习(带图片)
- 【牛腩新闻发布系统】——CSS学习
- QCustomPlot使用手册(一)
- 数据挖掘学习笔记1:引论
- uva 10523 Very Easy !!!
- 欧拉计划(10)Summation of primes
- 写博客的原因
- yuv420存储为JPG
- PowerDesigner--comment和name互相复制
- 【数据结构】回顾散列表
- 企业级监控平台开发之nagios二次开发(七)
- JSONObject与JSONArray的使用
- 第59题 Merge Two Sorted Lists
- poj2955 Brackets 简单区间dp