码迷,mamicode.com
首页 >  
搜索关键字:prime    ( 2475个结果
UVa 524 Prime Ring Problem【回溯】
题意:给出n,把从1到n排成一个环,输出相邻两个数的和为素数的序列照着紫书敲的, 大概就是这个地方需要注意下,初始化的时候a[0]=1,然后dfs(1),从第1个位置开始搜 1 #include 2 #include 3 #include 4 #include 5 #include 6...
分类:其他好文   时间:2015-03-21 01:04:18    阅读次数:247
F - Prime Path POJ 3126 筛选素数+bfs
F - Prime Path Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3126 Description The ministers of the cabinet were quite upset by the message from ...
分类:其他好文   时间:2015-03-20 22:08:07    阅读次数:170
【HDU】2138 How many prime numbers
http://acm.hdu.edu.cn/showproblem.php?pid=2138题意:给n个数判断有几个素数。(每个数using namespace std;typedef long long ll;ll ipow(ll a, ll b, ll m) { ll x=1; for(; b;...
分类:其他好文   时间:2015-03-20 14:06:29    阅读次数:128
Prime Ring Problem
Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30395Accepted Submission(s): 13525Problem Descript...
分类:其他好文   时间:2015-03-20 01:18:14    阅读次数:120
蓝桥杯 BASIC 16 分解质因数(数学)
【思路】:先打表,后循环。 【AC代码】: #include #include #include #include #include using namespace std; #define MAX 10000 int prime_list[MAX], cnt = 0; int isPrime(int n) { int i = 0; for (i = 2; i <= sqr...
分类:其他好文   时间:2015-03-19 23:58:45    阅读次数:481
UVa 294 - Divisors
通过这道题学到了2个知识: 1.一个数的质因子一定小于等于这个数的开根 2.一个数的因子(约数)数等于 π(各质因子数+1) #include #include #include #include using namespace std; const int maxn = 55555; //#define DEBUG int vis[maxn]; int prime[maxn]; int c...
分类:其他好文   时间:2015-03-18 14:10:25    阅读次数:126
UVa 10780 (质因数分解) Again Prime? No Time.
求mk整除n!,求k的最大值。现将m分解质因数,比如对于素数p1分解出来的指数为k1,那么n!中能分解出多少个p1出来呢?考虑10!中2的个数c:1~10中有10/2个数是2的倍数,c += 5;1~10中有10/4个数是4的倍数,所以c += 2,其中有10/8 = 1个数是8的倍数,所以c +=...
分类:其他好文   时间:2015-03-18 07:47:23    阅读次数:127
素数相关算法
1.素性测试//素性测试o(sqrt(n))1 int is_prime(int n)2 {3 for(int i=2;i*i divisor(int n) { 2 vector res; 3 for(int i=2;i*i prime_factor(int n) 2 {...
分类:编程语言   时间:2015-03-17 17:44:01    阅读次数:209
POJ 1679 prime次小生成树判定生成树是否唯一
The Unique MSTTime Limit:1000MSMemory Limit:10000KTotal Submissions:21931Accepted:7784DescriptionGiven a connected undirected graph, tell if its minim...
分类:其他好文   时间:2015-03-17 00:45:15    阅读次数:217
HDU 2138 How many prime numbers(Miller_Rabin法判断素数 【*模板】 用到了快速幂算法 )
How many prime numbersTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12955Accepted Submission(s):...
分类:编程语言   时间:2015-03-16 23:06:10    阅读次数:269
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!