Oil Skimming Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3426 Accepted Submission(s): 1432 Problem Description Thanks to a certain "green" resources company, there is a new profitabl…
Pollard-Rho 模板 板题-没啥说的- 求逆元出来后如果是负的记得加回正数 CODE #include<bits/stdc++.h> using namespace std; typedef long long LL; queue<int>arr; inline LL multi(LL a, LL b, LL p) { //快速乘 LL re = a * b - (LL)((long double) a / p * b + 1e-8) * p; return re <…
奔小康赚大钱 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12628 Accepted Submission(s): 5548 Problem Description 传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子.这可是一件大事,关系到人民的住房问题啊.村里共有n间房间,刚好有n家老百姓,考虑…
#include<cstdio> #include<algorithm> #include<cstring> #define N 80010 #define which(x) (ls[fa[(x)]]==(x)) using namespace std; int id[N],pos[N],sz[N],ls[N],rs[N],fa[N],tot,n,m,root,a[N]; ]; +sz[ls[x]]+sz[rs[x]];} int Build(int l,int r,i…
给定一棵有n个点的树 询问树上距离为k的点对是否存在. AC code: #include<bits/stdc++.h> using namespace std; const int MAXN = 10005; const int MAXM = 105; const int MAXK = 10000005; int n, m, q[MAXM]; int fir[MAXN], to[MAXN<<1], nxt[MAXN<<1], wt[MAXN<<1], cn…