projecteuler---->problem=10----Summation of primes
title:
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。
请求出200,0000下面全部质数的和。
import math,time
def isOk(a):
for i in range(2,int(math.sqrt(a))+1):
if a%i==0:
return False
return True
s=0
begin=time.time()
for i in range(2,2000000):
if isOk(i):
s += i
print s
end = time.time()
print end-begin
projecteuler---->problem=10----Summation of primes的更多相关文章
- Problem 10: Summation of primes
def primeslist(max): ''' 求max值以内的质数序列 ''' a = [True]*(max+1) a[0],a[1]=False,False for index in rang ...
- Project Euler Problem 10
Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of ...
- Problem 10
Problem 10 # Problem_10.py """ The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. ...
- (Problem 47)Distinct primes factors
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 7 15 = 3 5 The fi ...
- (Problem 37)Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- (Problem 35)Circular primes
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...
- uoj problem 10
uoj problem 10 题目大意: 给定任务若干,每个任务在\(t_i\)收到,需要\(s_i\)秒去完成,优先级为\(p_i\) 你采用如下策略: 每一秒开始时,先收到所有在该秒出现的任务,然 ...
- (Problem 10)Summation of primes
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two milli ...
- projecteuler Summation of primes
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two milli ...
- Summation of primes
是我算法不对,还是笔记本CPU太差? 我优化了两次,还是花了三四个小时来得到结果. 在输出上加1就是最终结果. The sum of the primes below 10 is 2 + 3 + 5 ...
随机推荐
- 洛谷—— P1908 逆序对
https://www.luogu.org/problem/show?pid=1908 题目描述 猫猫TOM和小老鼠JERRY最近又较量上了,但是毕竟都是成年人,他们已经不喜欢再玩那种你追我赶的游戏, ...
- luogu P1440 求m区间内的最小值
题目描述 一个含有n项的数列(n<=2000000),求出每一项前的m个数到它这个区间内的最小值.若前面的数不足m项则从第1个数开始,若前面没有数则输出0. 输入输出格式 输入格式: 第一行两个 ...
- [BZOJ 2427] 软件安装
Link: BZOJ 2427 传送门 Solution: 只看样例的话会以为是裸的树形$dp$…… 但实际上题目并没有说明恰好仅有一个物品没有依赖项 因此原图可能由是由多棵树与多个图组成的 先跑一遍 ...
- BZOJ 3669 [Noi2014]魔法森林(贪心+LCT)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3669 [题目大意] 给出一张图,每条边上有两个值ai和bi,现在需要求出一条1到N的路 ...
- 【树链剖分】bzoj2243 [SDOI2011]染色
树链剖分模板题.线段树维护每个段中的颜色数.左端点颜色.右端点颜色. pushup: col[rt]=col[rt<<1]+col[rt<<1|1]-(Rcol[rt<& ...
- bzoj 3540: [Usaco2014 Open]Fair Photography
3540: [Usaco2014 Open]Fair Photography Description FJ's N cows (2 <= N <= 100,000) are standin ...
- JVM堆 栈 方法区详解
一.栈 每当启用一个线程时,JVM就为他分配一个JAVA栈,栈是以帧为单位保存当前线程的运行状态 栈是由栈帧组成,每当线程调用一个java方法时,JVM就会在该线程对应的栈中压入一个帧 只有在调用一个 ...
- php红包
/** 转http://www.oschina.net/code/snippet_1392428_54532 谢谢 php_fangting * @param $total [你要发的红包 ...
- python一个简单的爬虫测试
之前稍微学了一点python,后来一直都没用,今天稍微做一个小爬虫试一试.. 参考了: http://www.cnblogs.com/fnng/p/3576154.html 太久没用了,都忘记pych ...
- iOS图片相似度比较
1. 缩小尺寸:将图像缩小到8*8的尺寸,总共64个像素.这一步的作用是去除图像的细节,只保留结构/明暗等基本信息,摒弃不同尺寸/比例带来的图像差异: 注:实际操作时,采取了两种尺寸作对比( ...