摘要: 题目链接:http://poj.org/problem?id=3628动态规划第二题,还是纯01背包题意:就是给出n和b,然后给出n个数,用这n个数中的某些,求出一个和,这个和是>=b的最小值,输出最小值与b的差。分析:这里的n个物品,每个物品的重量为c[i],价值为w[i]并且c[i]==w[i],,容量为所有c[i]的和sum。只要在f[]中从头开始找,找到一个最小>=b的就是题目要的解 1 ///2014.4.10 2 ///poj3628 3 4 #include 5 #include 6 #include 7 using namespace std; 8 9 int N, 阅读全文
posted @ 2014-04-10 19:27 basement_boy 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=362401背包问题,接触DP的第一题。 1 ///2014.4.10 2 ///poj3624 3 4 #include 5 #include 6 #include 7 using namespace std; 8 9 int N,M;10 int w[3500],c[3500];11 int f[13500];12 13 int main()14 {15 // freopen("in","r",stdin);16 // freopen("out","w&quo 阅读全文
posted @ 2014-04-10 18:25 basement_boy 阅读(93) 评论(0) 推荐(0) 编辑