摘要:
矩阵分治 注意不要用 ( this) 会改变原值 cpp include include include include include include using namespace std; int n, p, k; struct Matrix{ int num[35][35]; void cl 阅读全文
摘要:
树的直径 树的直径有两种求法 1.两遍 dfs 法, 便于输出具体方案,但是无法处理负权边 2.DP 法,代码量少,可以处理负权边 cpp include include include include include include using namespace std; const int M 阅读全文
摘要:
最短路 + 矩阵快速幂 我们可以改进矩阵快速幂,使得它适合本题 用图的邻接矩阵和快速幂实现 注意 dis[i][i] 不能置为 0 cpp include include include include include include using namespace std; struct edge 阅读全文
摘要:
floyd求无向图最小环 +输出路径 注意保存原来的边, 求最小环的时候要用 cpp include include include include include include include using namespace std; int n, m, dis[105][105], ans = 阅读全文
摘要:
二分答案 首先,最大值最小,就是二分答案 cpp include include include include include include include using namespace std; const int MAXN = 10005; int head[MAXN], nume, n, 阅读全文
摘要:
莫比乌斯函数 cpp include include include include include define ll long long using namespace std; const int MAXN = 500005; int T, a, b, k, miu[MAXN], prime[ 阅读全文
摘要:
期望 被精度坑惨的我 注意:能开 long long 尽量开, 先除后乘, int 转 double 的时候 先转换在做运算 本题与位运算有关,位与位之间互不影响,所以我们可以分开考虑 cpp include include include include include using namespa 阅读全文
摘要:
卢卡斯定理 注意特判底数和模数相等的情况 http://www.cnblogs.com/poorpool/p/8532809.html cpp include include include include include define ll long long using namespace st 阅读全文
摘要:
当 p 为质数时 $$c_m^n \equiv c_{m\%p}^{n\%p} c_{m/p}^{n/p}\pmod p$$ 模版,注意这其中的逆元求法 cpp include include include include include define ll long long using nam 阅读全文
摘要:
"题解" cpp include include include include include define ll long long using namespace std; const int MOD = 1e9 + 9, MAXN = 100005; int T, n, num[MAXN], 阅读全文
摘要:
逆序对 n 数码问题的扩展 对于一个n m 的问题来说,结论和 列数 m 奇偶有关 对于 m 是奇数来说 , 两个局面互相可达,当且仅当这两个局面按顺序写成一个数列,这个数列的逆序对数的奇偶性相同 对于 m 是偶数来说, 两个局面互相可达,当且仅当这两个局面按顺序写成一个数列,这个数列的逆序对数的差 阅读全文
摘要:
状压DP cpp include include include include include define ll long long using namespace std; const int MAXN = 3000; bool f[MAXN]; ll dp[14][MAXN], n, m; 阅读全文
摘要:
贪心 cpp include include include include include using namespace std; const int MAXN = 50005; int init() { int rv = 0, fh = 1; char c = getchar(); while 阅读全文
摘要:
贪心 首先以 miSPF 为关键字降序排列,然后对于每一头奶牛寻找满足范围的 SPF 值最大的防晒霜用, 我们发现,因为已经按最小值降序排列,所以对于下界来说若当前奶牛满足,之后的奶牛肯定满足,对上界来说, 对于 SPF[x] include include include include usin 阅读全文
摘要:
环形DP 先考虑如果只是一天,我们可以用线性DP写出转移方程,注意初始化 如果是一个环的话,我们发现少了一种第n天和第一天连起来的情况,那么我们就再进行一次DP 强制这种情况 cpp include include include include include using namespace st 阅读全文