背包
Acmer之家
ACM养成之路
展开
-
背包理论解析
背包之01背包、完全背包、多重背包详解 PS:大家觉得写得还过得去,就帮我把博客顶一下,谢谢。 首先说下动态规划,动态规划这东西就和递归一样,只能找局部关系,若想全部列出来,是很难的,比如汉诺塔。你可以说先把除最后一层的其他所有层都移动到2,再把最后一层移动到3,最后再把其余的从2移动到3,这是一个直观的关系,但是想列举出来是很难的,也许当层数n=3时还可以模拟下,再大一些就转载 2017-04-25 15:57:32 · 1628 阅读 · 0 评论 -
HDU---1114 Piggy-Bank【完全背包】
Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any small money, he takes原创 2017-04-16 14:57:02 · 262 阅读 · 0 评论 -
01背包问题
一、问题描述:有n 个物品,它们有各自的重量和价值,现有给定容量的背包,如何让背包里装入的物品具有最大的价值总和? 二、总体思路:根据动态规划解题步骤(问题抽象化、建立模型、寻找约束条件、判断是否满足最优性原理、找大问题与小问题的递推关系式、填表、寻找解组成)找出01背包问题的最优解以及解组成,然后编写代码实现; 三、动态规划的原理及过程: eg:number=4,capac转载 2017-10-14 20:42:28 · 883 阅读 · 0 评论 -
01背包装满
背包: 有n 种不同的物品,每个物品有两个属性,v体积,c价值,现在给一个体积为 m 的背包,问最多可带走多少价值的物品。 状态转移方程 dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i]]+c[i]) dp[i-1][j]表示不放第i件物品的最大价值,dp[i-1][j-v[i]]+c[i]表示放第i件物品的最大价值;[i-1][j-v[i]]这个表转载 2017-10-14 21:15:27 · 1184 阅读 · 0 评论 -
POJ---1837 Balance【01背包】
Description Gigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negligible weight and each arm's lengt原创 2018-03-03 16:42:24 · 201 阅读 · 0 评论 -
POJ---3628 Bookshelf 2【01背包】
Description Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only available space is at the top. FJ has N cows (1 ≤原创 2018-03-03 17:15:08 · 315 阅读 · 0 评论