HDU 1114 Piggy-Bank 完全背包 dp】的更多相关文章

The Highest Mark Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5501 Description 2045年的SD省队选拔,赛制和三十年前已是完全不同.一场比赛的比赛时间有 ttt 分钟,有 nnn 道题目. 第 iii 道题目的初始分值为 Ai(Ai≤106)A_i(A_i \leq 10^{6})A​i​​(A​i​​≤10​6​​) 分,之后每过一分…
http://acm.hdu.edu.cn/showproblem.php?pid=1011   题意:每个节点有两个值bug和brain,当清扫该节点的所有bug时就得到brain值,只有当父节点被清空时,才可以清扫它          的子节点,而清扫需要一定的人员.给定M个人员,N个结点的树,求最大brain和   这看起来是一道非常简单的背包dp 但是 写完提交wa之后,我发现这道题,并不简单!因为他的题意并不是完全和我找到的题意一样(我承认我语文很差劲所以随便找个题解看题意..),题目…
题目链接:HDU 5119 Problem Description Matt has N friends. They are playing a game together. Each of Matt's friends has a magic number. In the game, Matt selects some (could be zero) of his friends. If the xor (exclusive-or) sum of the selected friends'ma…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1114 题意 给出一个储钱罐 不知道里面有多少钱 但是可以通过重量来判断 先给出空储钱罐的重量 再给出装满钱币后储钱罐的重量 之后给出N种货币 pi wi pi 表示 第i件货币的价值 wi 表示第i件货币的重量 最后要求 储钱罐里面最少有多少钱 思路 完全背包模板问题 要注意初始化 因为这个是重量要刚好达到 初始化为 INF dp[0] = 0 AC代码 #include <cstdio> #in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114 题目大意:根据储钱罐的重量,求出里面钱最少有多少.给定储钱罐的初始重量,装硬币后重量,和每个对应面值硬币的重量. Sample Input 3 10 110 2 1 1 30 50 10 110 2 1 1 50 30 1 6 2 10 3 20 4   Sample Output The minimum amount of money in the piggy-bank is 60. The…
题意:给定一个体积,和一些物品的价值和体积,问你最大的价值. 析:最基础的01背包,dp[i] 表示体积 i 时最大价值. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream>…
Problem 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…
唔..近期在练基础dp 这道题挺简单的(haha).可是我仅仅想说这里得注意一个细节. 首先题意: 有T组例子,然后给出储蓄罐的起始重量E,结束重量F(也就是当它里面存满了零钱的时候).然后给你一个数N,代表如今有N种类型的硬币. 然后接下来N行,每行分别有两个数字P,W,P代表的是这样的类型零钱的价值,W则代表的是这样的类型零钱的重量,零钱的数量不限. 然后要你输出在满足当前重量就是F的情况下(也就是重量刚好为F),输出所需零钱价值最少的情况. 思路: 非常显然,这明显就是一个全然背包.可是这…
Jam's balance Problem Description Jim has a balance and N weights. (1≤N≤20)The balance can only tell whether things on different side are the same weight.Weights can be put on left side or right side arbitrarily.Please tell whether the balance can me…
差不多是一个裸的完全背包,只是要求满容量的最小值而已.那么dp值全部初始化为inf,并且初始化一下dp[0]即可.代码如下: #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; + ; + ; const int inf = 0x3f3f3f3f; int dp[W]; int val[N],w[N]; int main() { int T; scanf(&qu…