码迷,mamicode.com
首页 >  
搜索关键字:prime    ( 2475个结果
hdu 1233(还是畅通工程)(prime算法,克鲁斯卡尔算法)(并查集,最小生成树)
还是畅通工程 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26860    Accepted Submission(s): 11985 Problem Description 某省调查乡村交通状况,得到的统计表...
分类:编程语言   时间:2014-11-03 16:27:28    阅读次数:233
HDU 2136 Largest prime factor 参考代码
#include #include #include using namespace std; const int MAX=1000001; bool nums[MAX]; int indexes[MAX]; void eraosthenes() { int n=sqrt((double)MAX); for(int i=2; i<=n; i++) { ...
分类:其他好文   时间:2014-11-02 16:31:15    阅读次数:167
Poj 3126 Prime Path
1.Link:http://poj.org/problem?id=31262.Content:Prime PathTime Limit:1000MSMemory Limit:65536KTotal Submissions:11757Accepted:6675DescriptionThe minist...
分类:其他好文   时间:2014-11-02 01:58:12    阅读次数:218
noip知识点总结之--线性筛法及其拓展
一、线性筛法众所周知。。。线性筛就是在O(n)的时间里找出所有素数的方法code:void get_prime(int N){ int i, j, k; memset(Flag, sizeof(Flag), 0); for (i = 2; i N) break; ...
分类:其他好文   时间:2014-11-01 13:25:26    阅读次数:152
HDU 4135 Co-prime ( 容斥原理 )
HDU 4135 Co-prime ( 容斥原理 )#include #include using namespace std;typedef long long LL;#define MAXN 100int fac[ MAXN ], cnt;void gaoji( int x ) //对x质...
分类:其他好文   时间:2014-10-31 23:29:51    阅读次数:228
POJ 3006 Dirichlet's Theorem on Arithmetic Progressions 快筛质数
题目大意:给出一个等差数列,问这个等差数列的第n个素数是什么。 思路:这题主要考如何筛素数,线性筛。详见代码。 CODE: #include #include #include #include #define MAX 1000010 using namespace std; int prime[MAX],primes; bool notp[MAX]; int a...
分类:其他好文   时间:2014-10-31 12:02:10    阅读次数:199
hdu1016【dfs】
题目很简单,给出n(1 2 #include 3 using namespace std; 4 bool prime[40]; 5 bool hash[40]; 6 int ans[40]; 7 int n; 8 int cas = 1; 9 10 void getprime() {11 ...
分类:其他好文   时间:2014-10-30 20:41:33    阅读次数:229
poj3126--Prime Path(广搜)
Prime Path Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11751   Accepted: 6673 Description The ministers of the cabinet were quite upset by the message from...
分类:其他好文   时间:2014-10-30 17:08:51    阅读次数:194
hdu 4135 Co-prime(容斥原理)
http://acm.hdu.edu.cn/showproblem.php?pid=4135 求连续区间[a,b]内与n互质的数的个数。 因为a,b相当大,考虑用容斥原理。只需先求出[a,b]内与n不互质的数的个数,等于[1,b]内与n不互质的个数 - [1,a-1]内与n不互质的个数。问题转化为求【1,m】内与n不互质的数的个数。 先对n分解质因子,[1,m]内是n的质因子的倍数的...
分类:其他好文   时间:2014-10-30 00:27:50    阅读次数:266
O(n) 筛法求素数
var tot,i,j,k,m,n:longint; prime:array[0..100000] of boolean; p:array[0..100000] of longint;begin read(n); fillchar(prime,sizeof(prime),true); p...
分类:其他好文   时间:2014-10-28 21:13:10    阅读次数:174
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!