码迷,mamicode.com
首页 >  
搜索关键字:prime    ( 2475个结果
hdoj 1016 Prime Ring Problem
Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32717Accepted Submission(s): 144...
分类:其他好文   时间:2015-06-09 21:32:41    阅读次数:130
数学模板
把常用的数学模板放这里免得忘了素数表 1 int prime[maxn]; 2 void prime() 3 { 4 int i, j; 5 memset(prime, 1, sizeof(prime)); 6 for (i = 2; i 2 #include 3 usi...
分类:其他好文   时间:2015-06-09 19:50:31    阅读次数:128
计算第k个质因数只能为3,5,7的数
英文描述:Design an algorithm to find the kth number such that the only prime factorsare 3, 5, and 7思路:质因数只能为3,5,7,设这个数为val,则val = (3^i)(5^j)(7^n) (i,j,n>=...
分类:其他好文   时间:2015-06-09 19:35:03    阅读次数:92
二分查找/暴力 Codeforces Round #166 (Div. 2) B. Prime Matrix
题目传送门 1 /* 2 二分查找/暴力:先埃氏筛选预处理,然后暴力对于每一行每一列的不是素数的二分查找最近的素数,更新最小值 3 */ 4 #include 5 #include 6 #include 7 using namespace std; 8 9 cons...
分类:其他好文   时间:2015-06-09 17:00:33    阅读次数:177
openssl开源程序dh算法解析之dh_check.c
/*检查dh自身参数,dh公钥大小是否合适*/#include #include "cryptlib.h" #include //自定义OpenSSL 实现大数管理的结构及其函数 #include /*- * Check that p is a safe prime and * if g is 2, 3 or 5, c...
分类:编程语言   时间:2015-06-08 23:27:32    阅读次数:449
leetcode:Count Primes
Description:Count the number of prime numbers less than a non-negative number,n.本题给定一个非负数n,让我们求小于n的质数的个数,解题方法就在第二个提示埃拉托斯特尼筛法Sieve of Eratosthenes中,这个算...
分类:其他好文   时间:2015-06-08 22:57:05    阅读次数:153
hdu4135Co-prime 容斥原理水题
//问一个区间[a,b]与n互素的数的个数 //利用容斥原理可知 //在[a,b] 区间内对n的素数因子 //ans = 被一个数整除的数的个数 - 被两个数的最小公倍数整除的数的个数 + 被三个数的。。。 #include #include #include using namespace std ; const int maxn = 100010 ; typedef __in...
分类:其他好文   时间:2015-06-08 19:35:57    阅读次数:143
Java for LeetCode 204 Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.解题思路:空间换时间,开一个空间为n的数组,因为非素数至少可以分解为一个素数,因此遇到素数的时候,将其有限倍置为非素数,这样动态遍历+构造...
分类:编程语言   时间:2015-06-07 20:14:20    阅读次数:892
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
【leetcode】Count Primes
Description:Count the number of prime numbers less than a non-negative number, n. 1 class Solution { 2 public: 3 int countPrimes(int n) { 4 ...
分类:其他好文   时间:2015-06-07 12:33:06    阅读次数:109
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!