摘要: 显然题目要我们求 $2\sum_{i=1}^N \sum_{j=1}^M (i,j) NM$ 即 $2\sum_{i=1}^{\min(N,M)} \phi(i)\lfloor \frac{N}{i} \rfloor \lfloor \frac{M}{i} \rfloor NM$ 线筛+前缀和+整除 阅读全文
posted @ 2018-12-06 21:28 A·H 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 树状数组维护前缀最大值+扫描线DP cpp include"cstdio" include"cstring" include"iostream" include"algorithm" using namespace std; const int MAXN=1e5+5; int n,m,c,maxn; 阅读全文
posted @ 2018-12-06 20:04 A·H 阅读(167) 评论(0) 推荐(0) 编辑
摘要: fhq treap 开个 和`maxn`作排序标准 置顶就更新 ,垫底就更新 改变位置就相当于找前驱后继 找排名为 的编号就是二叉查找树的模板 找编号为 前面的书个数就拆树取左边的 cpp include"cstdio" include"cstring" include"iostream" incl 阅读全文
posted @ 2018-12-05 17:32 A·H 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 线性DP预处理+分组背包 首先设 表示该木板前 个格刷了 次且最后一次颜色为 的最大正确数 做下 的前缀和然后转移状态 然后对每个木板跑分组背包就可以了 cpp include"cstdio" include"cstring" include"iostream" include"algorithm" 阅读全文
posted @ 2018-12-04 18:36 A·H 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 考虑 运算的自反性 我们可以直接枚举二进制位异或来进行转移 这样边数大约是$n \log n$级别的 总复杂度$\Theta((n\log n+m)\log n)$ cpp include"cstdio" include"cstring" include"iostream" include"algo 阅读全文
posted @ 2018-12-04 15:03 A·H 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 状压DP $dp[i]$表示当前选人状态为$i$且选择了前$i.count()$个物品时最大的概率 cpp include"cstdio" include"cstring" include"iostream" include"algorithm" using namespace std; const 阅读全文
posted @ 2018-12-04 13:34 A·H 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 裸的二维数点 cpp include"cstdio" include"cstring" include"iostream" include"algorithm" using namespace std; const int MAXN=5e5+5; int n,m,maxn; int Tib[MAXN 阅读全文
posted @ 2018-12-04 12:49 A·H 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 单点修改+区间合并 若该区间最大值小于base, 若该区间为单点, 若该区间左区间最大值小于base, 否则 cpp include"cstdio" include"cstring" include"iostream" include"algorithm" using namespace std; 阅读全文
posted @ 2018-12-03 20:45 A·H 阅读(119) 评论(0) 推荐(0) 编辑
摘要: AC自动机在预处理fail的时候预处理下节点对应的匹配串的长度 这样复杂度就是严格$\Theta(n)$的 只需要一个栈,在trie图上跑就可以了 cpp include"cstdio" include"cstring" include"iostream" include"algorithm" us 阅读全文
posted @ 2018-12-03 17:00 A·H 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 为什么不试试手写bitset呢QAQ 存在字符 对应二进制第 位为1 这样就是线段树维护区间或了 cpp include"cstdio" include"cstring" include"iostream" include"algorithm" using namespace std; const 阅读全文
posted @ 2018-12-03 15:30 A·H 阅读(223) 评论(0) 推荐(0) 编辑