随笔分类 - acm / 模板
摘要:树上路径1 给你一个 个点的树。 给你 条树上的简单路径,每个路径有个权值 。 要求选择一些路径,使得每个点至多在一条路径上,并且路径的权值和最大。 输入格式 第一行两个整数n, m。 接下来一行n−1个数,$f_
阅读全文
摘要:FFT #include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < (int)b; i++) using namespace std; typedef double db; typedef long long ll; const
阅读全文
摘要:拆点 + 最大流 G - Erasing Prime Pairs (atcoder.jp) 题意 有 n(n <= 100)种互不相同的数,分别是 (<=1e7), 每个有 个 每次可以任意取两个数,如果相加是素数就消去这两个数,求最多操作次数 思路 思路一、 不考虑 1
阅读全文
摘要:#include <bits/stdc++.h> #define clog(x) std::clog << (#x) << " is " << (x) << '\n'; using ll = long long; // #include "include/izlyforever.hpp" names
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; using _T=double; // 全局数据类型,可修改为 long long 等 const _T eps=1e-8; const long double PI=3.141592653589793238
阅读全文
摘要:线段树 单点修改,区间查询 线段树2 - 题目 - Daimayuan Online Judge #include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <cmath> using
阅读全文
摘要:理想的正方形 二维倍增 SCUACM2022集训前训练-动态规划 - Virtual Judge (vjudge.net) 设 为以 为左上角,边长为 的正方形内元素的最大值 #include <iostream> #inclu
阅读全文
摘要:st表 #include <iostream> #include <cstring> #include <cmath> using namespace std; const int N = 2e5 + 10, M = 18; int f[N][M], a[N]; int n, m; void ini
阅读全文
摘要:Wormholes spfa 判负环 SCUACM2022集训前训练-图论 - Virtual Judge (vjudge.net) #include <iostream> #include <cstring> #include <algorithm> #include <vector> #incl
阅读全文
摘要:LCA 倍增 #include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <queue> using namespace std; typedef long long ll; const
阅读全文
摘要:线段树 区间加 ,区间和,区间最值,区间推平 #include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <cmath> #include <cstdio> using namespac
阅读全文
摘要:狄利克雷卷积 f, g 为数论函数 , 即 性质 满足交换律 满足结合律,即 \(p(n)=(f*g)*h=f*(g*h)=\sum\limits_{d_1*d_2*d_3=n}f(d_1)*
阅读全文
摘要:Lucas 定理 组合数取模 3 (适用于模数较小且为素数,组合数较大的情况) Lucas 定理 给定 n, m, p, p 为素数 把 n, m 拆解为 p 进制 \[ n=n_0*p^0+n_1*p^1+...+n_k*p^k\\ m=m_0*p^0+n_1*p^1+...+m_k*p^k\\
阅读全文
摘要:中国剩余定理 构造法(只适用模数两两互质的情况,CRT的本质思想) 对于解线性同余方程组 useless,因为完全可以被增量法代替 但是揭示了若模数两两互质,则线性同余方程组一定有解。 若模数为合数 , \(q=p_1^{e_1}*p_2^{e_2}*p_3^{e_3}*...p_k^{e
阅读全文