POJ 1384【完全背包】】的更多相关文章

所谓的全然背包,就是说物品没有限制数量的. 怎么起个这么intimidating(吓人)的名字? 事实上和一般01背包没多少差别,只是数量能够无穷大,那么就能够利用一个物品累加到总容量结尾就能够了. 本题要求装满的,故此添加个限制就能够了. #include <stdio.h> #include <stdlib.h> #include <string.h> inline int min(int a, int b) { return a < b? a : b; }…
题意:给出猪罐子的空质量和满质量,和n个硬币的价值和质量,求猪罐子刚好塞满的的最小价值. 思路:选择硬币,完全背包问题,塞满==初始化为无穷,求最小价值,min. 代码: #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define inf 10000000 int n,sum,empty,full,T; int v[600],w[600],dp[10050]; in…
http://poj.org/problem?id=1384 Piggy-Bank Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7900 Accepted: 3813 Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income f…
链接:http://poj.org/problem?id=1384 Piggy-Bank Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8893 Accepted: 4333 Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main incom…
POJ :http://poj.org/problem?id=1384 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2014 题目大意: 给定一个猪的存钱罐,它的初始重量和装满的重量,给你n种货币(包括它们的重量和价值),要求求最坏情况下装满这个猪所能获得的钱 依旧是完全背包的问题. 只不过一开始只有什么都不装有合法解,其他均为无穷大,即一开始dp[0]=0 然后改为求min而不是max(题目要求最坏情况下)…
Description 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 sma…
题意: 已知储蓄罐满时的质量f以及空时质量e, 有n种硬币,每种硬币的价值为p,质量为w, 求该储蓄罐中的最少有多少钱? 思路: 完全背包思想,问题是在一个重量下的最小价值 那么只要变一下符号就好了? //#include <bits/stdc++.h> #include<iostream> #include<string.h> #include<cstdio> #include<algorithm> using namespace std; t…
Piggy-Bank 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/F Description 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 Mone…
Piggy-Bank Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 10830   Accepted: 5275 Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from…
题目链接:https://vjudge.net/contest/217847#problem/A 题目大意:   现在有n种硬币,每种硬币有特定的重量cost[i] 克和它对应的价值val[i]. 每种硬币可以无限使用. 已知现在一个储蓄罐中所有硬币的总重量正好为m克, 问你这个储蓄罐中最少有多少价值的硬币? 如果不可能存在m克的情况, 那么就输出” This is impossible.”. 解题分析: 由于每种硬币可以无限使用, 所以是明显的完全背包问题,dp[i][j]为只用前i种硬币装满…