随笔分类 - 动态规划:背包问题
摘要:链接:https://www.luogu.org/problemnew/show/P1734 题面: 题目描述 选取和不超过S的若干个不同的正整数,使得所有数的约数(不含它本身)之和最大。 输入输出格式 输入格式: 输入一个正整数S。 输出格式: 输出最大的约数之和。 输入输出样例 输入样例#1:
阅读全文
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2844 思路:多重背包 , dp[i] ,容量为i的背包最多能凑到多少容量,如果dp[i] = i,那么代表这个数能凑出来,ans+1; 实现代码:
阅读全文
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2159 思路: dp[j][k] 代表消耗耐久度j,干掉k个敌人获得的经验值。 状态转移方程为: dp[j][k] = max(dp[j][k],dp[j-b[i]][k-1]+a[i]); 保存下当获得经验
阅读全文
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955 思路:一开始看急了,以为概率是直接相加的,wa了无数发,这道题目给的是被抓的概率,我们应该先求出总的逃跑概率,1-逃跑概率就是最后被抓的概率,dp的话,以所有银行总金额为容量,以单个银行的金额为体积,
阅读全文
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2546 思路:如果剩余金额大于五可以任意取,那么肯定是优先把金额最大的最后取,以金额m-5为容量 进行01背包,求得的最大金额加上最后取的物品,就是花费最大的。另外还有一个特殊情况当m<5时,此时什么物品都无
阅读全文
摘要:Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a ne
阅读全文
摘要:题目链接:http://codeforces.com/contest/611/problem/C 解题思路: 分别对矩阵横竖遍历,满足条件则加1,不满足则不变,先将整个矩阵都标记完,然后只要输出起点和终点数值的差值就行。有点动态规划的感觉。
阅读全文
摘要:C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output C. Dasha and Passw
阅读全文
摘要:Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines.Half of these c
阅读全文
摘要:A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time
阅读全文
摘要:hdu1024 Max Sum Plus Plus Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more
阅读全文
摘要:Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this
阅读全文
摘要:题目: Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irr
阅读全文