模板
文章平均质量分 56
自在_飞花
这个作者很懒,什么都没留下…
展开
-
二分图匹配
using namespace std;const LL MAXN = 9000001;struct N{ unsigned int v,next;}edge[MAXN*2];int head[MAXN];int Top;void Link(unsigned int u,unsigned int v){ edge[Top].v = v; edge原创 2015-04-23 21:35:19 · 693 阅读 · 0 评论 -
树链剖分模板
#include #include #include #include #include #include #include #include #define LL long long#define EPS (1e-8)#define INF 0x3f3f3f#pragma comment(linker, "/STACK:1024000000,1024000000")原创 2015-04-22 20:46:19 · 547 阅读 · 0 评论 -
最小费用最大流模板
const int MAXN = 10000;const int MAXM = 100000;struct Edge{ int to,next,cap,flow,cost;}edge[MAXM];int head[MAXM],tol;int pre[MAXN],dis[MAXN];bool vis[MAXN];int N;void Init(int n){ N原创 2015-04-22 21:42:45 · 583 阅读 · 0 评论 -
组合数取余(Mod 可以不为质数)
using namespace std;const int MAXN = 200005;bool ispri[MAXN];int prime[MAXN];int priCnt;void CalPrime(){ priCnt = 0; memset(ispri,false,sizeof(ispri)); for(int i = 2;i < MAXN; ++原创 2015-06-24 16:56:29 · 1697 阅读 · 0 评论 -
有向图的强联通分量 tarjan
多与DAG上的DP之类的问题一起出现。using namespace std;const int MAXE = 300010;const int MAXP = 100010;struct N{ int v,next;}edge[MAXE];int head[MAXP];int Top;int ty[MAXP];int high[MAXP];int low原创 2015-05-15 10:38:45 · 961 阅读 · 0 评论 -
树的重心
拿掉重心后,最大的联通分量的点的个数最少。using namespace std;const int MAXE = 80010;const int MAXP = 40010;struct EDGE{ int v,next;}edge[MAXE];int head[MAXP];int Top;void Link(int u,int v){ edge[Top原创 2015-05-16 08:53:23 · 686 阅读 · 0 评论 -
无向图求割点
using namespace std;const int MAXE = 300010;const int MAXP = 1010;struct N{ int v,next;}edge[MAXE*2];int head[MAXP];int Top;int high[MAXP];int low[MAXP];int subnet[MAXP];int dfsClock;原创 2015-05-15 15:04:13 · 994 阅读 · 0 评论 -
SPOJ DQUERY 区间内不同数的个数 主席树
#include #include #include #include #include using namespace std;const int MAXN = 30010,MAXLOG = 20;struct ChairTree{ int l,r; int ans;}ct[MAXN*MAXLOG];int ctRoot[MAXN];int ctTop原创 2015-04-28 14:56:15 · 903 阅读 · 0 评论 -
ZOJ 2112 Dynamic Rankings BIT套ChairTree
劳资就是想单纯的测个模板,怎么就特喵的这么难。首先说一下自己对主席树的理解。作用:确定区间[L,R]内的第K大数,或者区间内有多少个不同个元素。主席树的另一个名字叫做函数式线段树,然后我查了一下函数式的特点,其中之一就是不修改状态。从主席树上来看这个特点就是:在向主席树插入第 i 个元素之后,我们仍能查询到没插入 i 之前的状态。主席树的构造:对于有n个元素,s个不同元原创 2015-04-21 14:27:00 · 680 阅读 · 0 评论 -
原根
定理:如果m有原根,那么它一定有φ(φ(m))个原根。求模素数P原根的方法:对p-1素因子分解,得到top个素因子,若有(g^((P-1)/FACi))%P != 1%P (1原创 2015-04-09 12:26:35 · 883 阅读 · 0 评论 -
欧拉素数筛
const int MAXN = 1000;//上限bool mark[MAXN];int phi[MAXN];//欧拉函数值int prime[MAXN];//素数int Top;//素数个数void GetPhiandPrimeTable(int n){ memset(mark,false,sizeof(mark)); phi[1] = 1; Top =原创 2015-04-09 11:06:16 · 718 阅读 · 0 评论 -
大素数判断和素因子分解(miller-rabin,Pollard_rho算法)
#include #include #include #include #include #include #include #include #pragma comment(linker, "/STACK:1024000000")#define LL long long int#define INF 0x3f3f3f3fusing namespace std;con原创 2015-04-09 11:14:50 · 898 阅读 · 0 评论 -
在线LCA
const int MAXN = 10010; const int MAXM = 10010; struct N { int v,w,next; }edge[MAXM*2]; int Top; int head[MAXN]; int MAXSIZE; int dep[MAXN]; int seq[MAXN*2]; int R[MAXN];原创 2015-04-08 16:52:31 · 691 阅读 · 0 评论 -
允许重复数字的划分树
const int MAXN = 50010,MAXM = 20;int num[MAXN],tmp[MAXN],pre[MAXN];int ans[MAXM][MAXN],val[MAXM][MAXN];void Init(int l,int r,int h){ if(l == r) return ; //printf("l = %2d r = %2原创 2015-04-08 16:49:02 · 611 阅读 · 0 评论 -
最大流 ISAP
const int MAXN = 2010;//点数const int MAXM = 400010;//正向弧和反向弧的数量struct Edge{ int to,next,cap,flow;} edge[MAXM];int Top;int head[MAXN];int gap[MAXN],dep[MAXN],cur[MAXN];void Init(){原创 2015-06-26 20:04:15 · 802 阅读 · 0 评论