码迷,mamicode.com
首页 >  
搜索关键字:primes    ( 339个结果
质数筛选方法(埃拉托斯特尼筛法)
今天刷题刷了这么一道题, 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,接着求2000000以内质数加法的和。 分析:要求2000000内质数的和,首先得把...
分类:其他好文   时间:2015-07-11 09:18:17    阅读次数:137
LeetCode Count Primes 求素数个数
题意:给一个数n,返回小于n的素数个数。思路: 1 class Solution { 2 public: 3 int countPrimes(int n) { 4 bool* isPrime =new bool[n] ; 5 6 memset...
分类:其他好文   时间:2015-06-26 22:19:55    阅读次数:123
Leetcode--easy系列9
#198 House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them...
分类:其他好文   时间:2015-06-25 21:16:15    阅读次数:110
Count Primes ——LeetCode
Description:Count the number of prime numbers less than a non-negative number,n.题目大意:给一个int,返回小于它的质数的数量。解题思路:打表。public class Solution { public ...
分类:其他好文   时间:2015-06-25 11:55:16    阅读次数:93
欧拉计划(python) problem 27
Quadratic primes Problem 27 Euler discovered the remarkable quadratic formula: n² + n + 41 It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. Howe...
分类:编程语言   时间:2015-06-17 21:37:46    阅读次数:149
Project Euler:Problem 50 Consecutive prime sum
The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest s...
分类:其他好文   时间:2015-06-07 17:35:13    阅读次数:129
Project Euler:Problem 47 Distinct primes factors
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 × 7 15 = 3 × 5 The first three consecutive numbers to have three distinct prime factors are: 644 = 2² × 7 × 23 ...
分类:其他好文   时间:2015-06-07 11:08:41    阅读次数:106
Lettcode_204_Count Primes
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/46366207 Description: Count the number of prime numbers less than a non-negative number, n. 思路: (1)题意为给定整数n,求解n以内的整数中有多少个素数(质数)。 (2)该题涉及到数学相关的知识。首先,看下素数的定义:质数(prime...
分类:其他好文   时间:2015-06-04 22:51:54    阅读次数:142
sicily 1259 Sum of Consecutive Primes
又水,素数只能是连续的,而且最多才10000! 1 #include 2 3 using namespace std; 4 5 int a[10001]; 6 7 bool is_prime(int x) 8 { 9 if(x == 1) return 0;10 for...
分类:其他好文   时间:2015-06-02 21:25:09    阅读次数:122
Project Euler:Problem 27 Quadratic primes
Euler discovered the remarkable quadratic formula: n² + n + 41 It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40...
分类:其他好文   时间:2015-06-02 11:16:49    阅读次数:139
339条   上一页 1 ... 23 24 25 26 27 ... 34 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!