摘要: 大于k的部分直接加k 对于小于等于k的cnt个数 ans=cnt*k - Σ(k/i * i) 然后k/i在一段区间内不变,这段区间直接可以数列求和 # include <bits/stdc++.h> # define IL inline # define RG register # define 阅读全文
posted @ 2017-12-19 20:41 Cyhlnj 阅读(129) 评论(0) 推荐(0)
摘要: CDQ套CDQ或者CDQ套树套树 前者快于后者然而我写了后者 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # define IL in 阅读全文
posted @ 2017-12-19 19:37 Cyhlnj 阅读(235) 评论(0) 推荐(0)
摘要: CDQ分治或树套树可以切掉 CDQ框架: 先分 计算左边对右边的贡献 再和 所以这个题可以一维排序,二维CDQ,三维树状数组统计 CDQ代码 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algori 阅读全文
posted @ 2017-12-19 19:34 Cyhlnj 阅读(223) 评论(0) 推荐(0)
摘要: CDQ分治 把删除转变为逐个添加,于是就变成了三维偏序问题 时间,位置,大小 分两遍统计即可 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h 阅读全文
posted @ 2017-12-19 19:28 Cyhlnj 阅读(236) 评论(2) 推荐(0)
摘要: LCT a排序后做b的kruskal splay维护最大边的位置,若当前大,不加,否则cut,加边 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <strin 阅读全文
posted @ 2017-12-17 20:31 Cyhlnj 阅读(237) 评论(0) 推荐(0)
摘要: LCT 暴力建图后只有cut link 建个超级点 次数即size # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # define IL 阅读全文
posted @ 2017-12-17 20:29 Cyhlnj 阅读(154) 评论(0) 推荐(0)
摘要: LCT模板 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # define IL inline # define RG register 阅读全文
posted @ 2017-12-17 20:26 Cyhlnj 阅读(250) 评论(0) 推荐(0)
摘要: map加LCT水一下就过了 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # include <map> # define IL inl 阅读全文
posted @ 2017-12-17 20:24 Cyhlnj 阅读(192) 评论(0) 推荐(0)
摘要: 倒过来就变成了加边 然后就直接LCT # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # define IL inline # defin 阅读全文
posted @ 2017-12-17 20:23 Cyhlnj 阅读(128) 评论(0) 推荐(0)
摘要: LCT板子,打个lazy即可 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # include <map> # define IL in 阅读全文
posted @ 2017-12-17 20:19 Cyhlnj 阅读(156) 评论(0) 推荐(0)
摘要: 树分治 求逆元请递推,不然会TLE 开桶记录即可 注意常数 # pragma comment(linker,"/STACK:102400000,102400000") # include <stdio.h> # include <stdlib.h> # include <iostream> # in 阅读全文
posted @ 2017-12-12 19:40 Cyhlnj 阅读(283) 评论(0) 推荐(0)
摘要: 树分治,每次把每个点的deep取出,排序。。。尺取法。。。 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # define IL inl 阅读全文
posted @ 2017-12-12 19:37 Cyhlnj 阅读(148) 评论(0) 推荐(0)
摘要: 树分治,每次统计时有两种组合%3==2和%3==1, %3==0和%3==0 乘法原理即可 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> 阅读全文
posted @ 2017-12-12 19:36 Cyhlnj 阅读(147) 评论(0) 推荐(0)
摘要: map+floyed+矩阵乘法(倍增floyed) # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # include <map> # d 阅读全文
posted @ 2017-12-12 19:32 Cyhlnj 阅读(124) 评论(0) 推荐(0)
摘要: KMP暴力求出next数组后 实际上是一个最短路问题,floyed搞一搞 然而会TLE 矩阵优化一下即可(倍增floyed) KMP在弱数据下可以AC。。正解请看其他人博客 # include <stdio.h> # include <stdlib.h> # include <iostream> # 阅读全文
posted @ 2017-12-12 19:31 Cyhlnj 阅读(340) 评论(0) 推荐(0)
摘要: AC自动机建立fail树后树上DP # include <stdio.h> # include <stdlib.h> # include <iostream> # include <string.h> # include <algorithm> # include <queue> # define 阅读全文
posted @ 2017-12-12 19:27 Cyhlnj 阅读(199) 评论(0) 推荐(0)
摘要: 显然知道一个节点就可以推出整棵树 然而直接乘会爆longlong 所以考虑取log 最后排序算众数即可 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <str 阅读全文
posted @ 2017-12-12 19:19 Cyhlnj 阅读(172) 评论(0) 推荐(0)
摘要: 有点像SDOI仪仗队 注解见代码 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> # define IL inline # define 阅读全文
posted @ 2017-12-12 19:15 Cyhlnj 阅读(98) 评论(0) 推荐(0)
摘要: 实际上就是求Gcd(i - 1, j - 1) == 1 的 (i, j) i >= 2, j >= 2 的个数加2 i - 1 和 j - 1 互质 那不就是sigma phi(i - 1) 最后答案*2+1即可 # include <stdio.h> # include <stdlib.h> # 阅读全文
posted @ 2017-12-12 19:12 Cyhlnj 阅读(133) 评论(0) 推荐(0)
摘要: jzoj snow的追寻 DFS序上搞 合并暴力和,记录最长链和当前最远点,距离跑LCA # include <stdio.h> # include <stdlib.h> # include <iostream> # include <algorithm> # include <string.h> 阅读全文
posted @ 2017-12-09 11:20 Cyhlnj 阅读(306) 评论(0) 推荐(0)