码迷,mamicode.com
首页 >  
搜索关键字:calculate prime s    ( 3428个结果
UVA 10780 Again Prime? No Time.
本题求m的最大多少次幂是 n!的因子;也就是质因子分解 n!中某一质因子个数与m中质因子个数比的最小值。#include #include using namespace std;int sign[10010];int pri[10010];int tot;int e2[10010][1500],e...
分类:其他好文   时间:2014-07-22 22:56:35    阅读次数:239
POJ 3978 Primes(素数筛选法)
题目简单的计算A,B之间有多少个素数只是测试数据有是负的//AC//A和B之间有多少个素数//数据可能有负的!!!#include#include//素数筛选法int pri[100000+10];//1 合数, 0 素数void Prime(){ memset(pri,0,sizeof(pr...
分类:其他好文   时间:2014-07-19 20:04:10    阅读次数:266
D_Dp
/* D - 简单dp 例题 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum ...
分类:其他好文   时间:2014-07-18 22:23:25    阅读次数:231
UVA 11762 - Race to 1(概率)
UVA 11762 - Race to 1 题意:给定一个n,每次随即选择一个n以内的质数,如果不是质因子,就保持不变,如果是的话,就把n除掉该因子,问n变成1的次数的期望值 思路:tot为总的质数,cnt为质因子个数,那么f(n)=(1?cnt/tot)?f(n)+∑f(n/prime)?(1/tot),然后利用记忆化搜索去做即可 代码: #include #inclu...
分类:其他好文   时间:2014-07-17 15:36:46    阅读次数:211
POJ 2109 Power of Cryptography
Description Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers among these primes. Work in this area has resulted in the practical use of...
分类:其他好文   时间:2014-07-17 10:12:16    阅读次数:191
hoj 2275 Number sequence
Number sequence Given a number sequence which has N element(s), please calculate the number of different collocation for three number Ai, Aj, Ak, which satisfy that Ai Ak and i Input The fi...
分类:其他好文   时间:2014-07-16 09:51:23    阅读次数:201
hdu1016Prime Ring Problem深搜
#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;int n;int prime[100];void Prime(){ for(...
分类:其他好文   时间:2014-07-16 00:58:49    阅读次数:363
Ugly Numbers(1.5.8)
Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Description Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence  ...
分类:其他好文   时间:2014-07-14 14:03:02    阅读次数:206
python中的小技巧
1.求1~100以内的素数prime=filter(lambda x: not [x%i for i in range(2,x) if x%i==0], range(2,101))#列表推导,一行搞定.print prime2.求字符串子串s='hauifnefldmfp'[s[i:i+n] for...
分类:编程语言   时间:2014-07-13 23:39:55    阅读次数:296
(素数求解)I - Dirichlet's Theorem on Arithmetic Progressions(1.5.5)
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description If a and d are relatively prime positive integers, the arithmetic sequence begin...
分类:其他好文   时间:2014-07-13 18:53:13    阅读次数:251
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!