上一页 1 2 3 4 5 6 7 8 9 10 ··· 26 下一页
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1799 【题解】 一眼看过去,数位dp! 想了想,发现数字和最多也就是$m = 9 \times 18 = 162$种,好像不是很大。 考虑枚举每种数字和$p$,做一遍dp。 设$f_{i,j, 阅读全文
posted @ 2017-07-03 22:17 Galaxies 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2005 【题解】 题目要求$\sum_{i=1}^n\sum_{j=1}^m ((i,j) * 2 + 1)$ 考虑容斥,$t_i$表示有公约数$i$的方案数,显然是$\lfloor n/i \ 阅读全文
posted @ 2017-07-03 19:50 Galaxies 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4039 【题解】 曼哈顿距离没法把坐标分开来计算,使得$x$部分最小,不一定就能使得$y$部分最小。 只能先转成切比雪夫距离(是可以实现上面的功能的),那么每个点的可行区域就是一个边平行于坐标轴 阅读全文
posted @ 2017-07-03 15:52 Galaxies 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2516 【题解】 状压dp。 $f_{sta,i}$表示状态为sta,当前在第i层的最小花费时间。状态是个三进制表示,0代表没进过电梯;1代表在电梯里;2表示进过电梯,出来了。 然后考虑当前状态 阅读全文
posted @ 2017-07-03 13:23 Galaxies 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 传送门:https://loj.ac/problem/516 【题解】 那段代码求的是相同的数中间隔最小的值。 离散后用set维护每个值出现次数,每次操作相当于合并两个set,这步可以启发式合并。 加元素的时候直接找前驱和后继即可。 学了新姿势:set中insert有返回的,可以访问.first来调 阅读全文
posted @ 2017-07-03 10:14 Galaxies 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 传送门:https://loj.ac/problem/515 【题解】 容易发现S最大到1000000。 于是我们有一个$O(n^2*S)$的dp做法。 容易发现可以被bitset优化。 于是复杂度就是$O(\frac{n^2S}{32})$ 然后……就过了 # include <bitset> # 阅读全文
posted @ 2017-07-03 10:11 Galaxies 阅读(502) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3043 【题解】 比较神奇的一道题,开始没往差分的角度上想,所以没想出来。 考虑查分数组,有$n-1$个数,那么操作变成一个地方+1,一个地方-1. 显然最后是要让差分数组全部变成0. 设差分后 阅读全文
posted @ 2017-07-03 08:55 Galaxies 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2216 【题解】 决策单调性,证明容易,略。 用整体二分的那个trick可以方便实现代码。 复杂度$O(nlogn)$ # include <math.h> # include <stdio.h 阅读全文
posted @ 2017-07-02 22:45 Galaxies 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 原题传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2687 【题目大意】 给出若干区间,求一个区间的大于等于2的子集,使得 |区间并| 和 |区间交| 的乘积最大。 $1\leq n,L_i,R_i\leq 10^6$ 【题解】 把区间去掉包 阅读全文
posted @ 2017-07-02 22:17 Galaxies 阅读(453) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5909 【题解】 设$f_{x,i}$表示以$x$节点的子树中,权值为$i$的子树个数,其中$x$必选。 那么有dp方程:$f_{x,i} = \sum_{y = son[x]} f_{x,i} + \su 阅读全文
posted @ 2017-07-02 17:06 Galaxies 阅读(185) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 26 下一页