摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2546http://blog.csdn.net/xujinsmile/article/details/7969412首先拿出5元买最贵的东西,那接下来就是背包容量m-5,物品数量n-1 的01背包问题了。做背包问题... 阅读全文
posted @ 2015-12-09 22:29 qlky 阅读(212) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2955这道题求不被抓时的最大金钱。金额是整数,概率是小数。因为数组小标不能是小数,所以我们可以以钱作为weight,概率作为value。这说明解背包问题时cost和weight不是定死的,是可以相互转换的。以银行的... 阅读全文
posted @ 2015-12-09 17:50 qlky 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 背包九讲奉上http://love-oriented.com/pack/P01.html以HDU 2602为例:http://acm.hdu.edu.cn/showproblem.php?pid=2602初始化的细节问题我们看到的求最优解的背包问题题目中,事实上有两种不太相同的问法。有的题目要求“恰... 阅读全文
posted @ 2015-12-07 16:43 qlky 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 在一个NxN的棋盘上,每个格子里有若干个棋子,假设起点为左上角的格子,且每次只能向下或向右走一格,问怎样走才能得到最多的棋子。这是很简单的递推题了。因为只能向下或者向右,所以其实我们可以把棋盘看成一颗这样的树(以N=3为例)起点最上,终点最下,数字即为棋子,只能向下走,要找一条数字总和最大的路线。这... 阅读全文
posted @ 2015-12-06 18:49 qlky 阅读(664) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4489解题思路这里已经说的很清楚了:http://blog.csdn.net/bossup/article/details/9915647这里就说下遇到这种问题应该怎么想。因为是排列问题,一般都是从某个点开始推,寻... 阅读全文
posted @ 2015-12-06 16:41 qlky 阅读(426) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4747 阅读全文
posted @ 2015-12-06 01:31 qlky 阅读(128) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5170 参考: http://blog.csdn.net/cc_again/article/details/24841249 UPDATE: 第二次做的感受,说下这道题为什么用递推 阅读全文
posted @ 2015-12-06 00:10 qlky 阅读(383) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/problemset/problem/429/B 可以参考这篇文章: http://blog.csdn.net/pure_lady/article/details/46764839 因为有断点,所以可以预处理四个顶点到任意点的距离最大值,通过拼接得到断点后 阅读全文
posted @ 2015-12-05 21:08 qlky 阅读(469) 评论(2) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2084状态转移方程:dp[i][j] =MAX(dp[i+1][j],dp[i+1][j+1])+tower[i][j]#include #include #include #include #include #i... 阅读全文
posted @ 2015-12-05 17:16 qlky 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #include#include#includeusing namespace std;int gcd(int x,int y){ if(!y) return x; else return... 阅读全文
posted @ 2015-12-05 01:34 qlky 阅读(152) 评论(0) 推荐(0) 编辑