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 ...
随机推荐
- IO复用之epoll系列
epoll是什么? epoll是Linux内核为处理大批量文件描述符而作了改进的poll,是Linux下多路复用IO接口select/poll的增强版本,它能显著提高程序在大量并发连接中只有少量活跃的 ...
- PTA L2-023 图着色问题-前向星建图 团体程序设计天梯赛-练习集
L2-023 图着色问题 (25 分) 图着色问题是一个著名的NP完全问题.给定无向图,,问可否用K种颜色为V中的每一个顶点分配一种颜色,使得不会有两个相邻顶点具有同一种颜色? 但本题并不是要你解 ...
- LOJ #6277. 数列分块入门 1-分块(区间加法、单点查询)
#6277. 数列分块入门 1 内存限制:256 MiB时间限制:100 ms标准输入输出 题目类型:传统评测方式:文本比较 上传者: hzwer 提交提交记录统计测试数据讨论 2 题目描述 给出 ...
- 167. Two Sum II - Input array is sorted【Easy】【双指针-有序数组求两数之和为目标值的下标】
Given an array of integers that is already sorted in ascending order, find two numbers such that the ...
- NBUT 1223 Friends number
暴力,打表. 计算出每一个数的因子之和,可以枚举$i$,让后将$i$的倍数都加上$i$.发现这样的只有$71$对,然后暴力就可以了. #include<cstdio> #include&l ...
- Java GlassPane进度条遮罩
package com.swing.demo; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Flo ...
- Beaglebone Black教程使用SSH通过USB和因特网连接Beaglebone Black
Beaglebone Black教程使用SSH通过USB和因特网连接Beaglebone Black 使用SSH通过USB和因特网连接Beaglebone Black SSH是Secure Shell ...
- 手机上编程,编写android apk
韩梦飞沙 yue31313 韩亚飞 han_meng_fei_sha 313134555@qq.com C4Droid:在手机上直接编程,然后导出为apk
- 浙南联合训练赛 H - The number of positions
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say ...
- uva1632 (区间DP)
题意:有n个宝藏,在x轴上,每个宝藏在某个时间会消失,问最少吃完所有宝藏的时间是多少,否则输出no solution 分析:区间DP,f[i][j][01]代表i到j区间内的全部吃完,停留在左/右端, ...