背包问题
EnjoyingAC
bugger,写bug爱好者。
展开
-
POJ3624 Charm Bracelet(01背包问题)
题目链接http://poj.org/problem?id=3624题意给定N种物品的价值v[i]和重量w[i],每一种物品只有一个,求用一个最多能装重量为M的背包所能装物品的最大价值。题解01背包问题。 设dp[i]表示容量为i的背包所能获得的最大价值。 决策:第i种物品是否放入背包。 状态转移方程:dp[i]=max(dp[i],dp[i-w[i]]+v[i])。代码#include <c原创 2017-12-22 19:08:25 · 214 阅读 · 0 评论 -
第十四届华中科技大学程序设计竞赛决赛同步赛 Beautiful Land(01背包变形)
题目链接 Beautiful Land 题目 It’s universally acknowledged that there’re innumerable trees in the campus of HUST. Now HUST got a big land whose capacity is C to plant trees. We have n trees which could...原创 2018-05-07 12:37:46 · 171 阅读 · 0 评论