HDU 5188 背包】的更多相关文章

有N道题.要求得到最少W分 给出N道题的:每道题用时T.分数V,应在且必须在L时刻提交才干得分 问得到W分所用的最少的时间 以L-T排序,然后做01背包就可以 #include "stdio.h" #include "algorithm" #include "string.h" using namespace std; struct Mark { int t,v,l,x; }mark[40]; int dp[300010]; bool cmp(M…
传送门 zhx and contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 145    Accepted Submission(s): 49 Problem Description As one of the most powerful brushes in the world, zhx usually takes part…
zhx and contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 757    Accepted Submission(s): 282 Problem Description As one of the most powerful brushes in the world, zhx usually takes part in…
Problem Description As one of the most powerful brushes in the world, zhx usually takes part in all kinds of contests. One day, zhx takes part in an contest. He found the contest very easy for him. There are n problems in the contest. He knows that h…
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28020    Accepted Submission(s): 9864 Problem Description Nowadays, we all know that Computer College is the biggest department…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1171 Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) 问题描述 Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you…
题目地址http://acm.hdu.edu.cn/showproblem.php?pid=2602 #include <stdio.h> #include <string.h> int main() { ],f[],va[]; int i,j,k,n,m; scanf("%d",&k); while(k--) { memset(f,,sizeof(f)); scanf("%d%d",&n,&m); ;i<n;i…
1171 题意比较简单,这道题比较特别的地方是01背包中,每个物体有一个价值有一个重量,比较价值最大,重量受限,这道题是价值受限情况下最大,也就值把01背包中的重量也改成价值. //Problem : 1171 ( Big Event in HDU ) Judge Status : Accepted #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> us…
Big Event in HDU Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Computer College and Software College in 2002.The splitting is…
题目链接: H - Partial Tree  HDU - 5534 题目大意:首先是T组测试样例,然后n个点,然后给你度数分别为(1~n-1)对应的不同的权值,然后问你在这些点形成树的前提下的所能形成的最大权值. 具体思路: 这个题是学长做的,我记录一下思路. 有点背包的感觉,但是和之前我做过的有点不同,原来的背包是互相不会影响的.但是对于这个题,我们需要的前提是形成一棵树,所以为了解决这个问题,我们先给每个点分配一个度,然后再去把剩余的n-2的度再分配下去就可以了. AC代码: #inclu…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1171 题意:把商品分成两半,如不能均分,尽可能的让两个数相接近.输出结果:两个数字a,b且a>=b. 思路:01背包. 先把商品的总价值计算出来,sum/2做为背包的容量. 然后讲同种商品的多件,存储为不同商品 同样价值的形式,也就是我们用一个一维数组来存储,不用一个二维或是两个一维数组来存. 感想:好久没有做背包的题目了,今天来做,忘了好多思路,这提醒着我,学习不能一直都在学新东西,也要及时的复习.…
http://acm.hdu.edu.cn/showproblem.php?pid=1171 多重背包题目不难,但是有些点不能漏或错. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #define lson l, m, rt<<1 #define rson…
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 40976 Accepted Submission(s): 14090 Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe yo…
http://poj.org/problem?id=3624 背包中最基础的01背包,大意是有N件物品和一个容量为V的背包.第i件物品的费用是c[i],价值是w[i].求解将哪些物品装入背包可使价值总和最大 主要是要有动态规划的思想,列出每个容量下的最大值,每次只考虑取或不取两种情况<一个状态一个状态的转移 #include<iostream> #include<cstring> using namespace std; ]; ],d[]; int main() { int…
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 51789    Accepted Submission(s): 17690 Problem Description Nowadays, we all know that Computer College is the biggest department…
Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4824    Accepted Submission(s): 2514 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took par…
B - Big Event in HDU Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Computer College and Software College in 2002. The splitting is absolutely a b…
题目地址:HDU 1171 还是水题. . 普通的01背包.注意数组要开大点啊. ... 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #incl…
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 51181    Accepted Submission(s): 17486 Problem DescriptionNowadays, we all know that Computer College is the biggest department…
Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Computer College and Software College in 2002.The splitting is absolutely a big…
J - 10 Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5234 Description Today is Gorwin’s birthday. So her mother want to realize her a wish. Gorwin says that she wants to eat many cakes. Thus,…
http://acm.hdu.edu.cn/showproblem.php?pid=1248 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #define maxn 11000 using namespace std; int dp[maxn]; int main() { int T, n; scanf("%d", &…
Piggy-Bank  HDU 1114 初始化的细节问题: 因为要求恰好装满!! 所以初始化要注意: 初始化时除了F[0]为0,其它F[1..V]均设为−∞. 又这个题目是求最小价值: 则就是初始化时除了F[0]为0,其它F[1..V]均设为∞. #include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; const int…
DP还有很长很长一段路要走.. 题意:给出n纪念品的价格和钱数m,问最多能买多少件纪念品和买这些数量的纪念品的方案数. 首先,求能买最多的纪念品的数量,用贪心法可以解决.将价钱排序,然后从最便宜的开始买,这样就很容易求得最多买的纪念品的数量. 方案数就要用到动态规划. dp[j][k]表示花费不超过j元买k件物品的方案数 dp[j][k] += dp[j-a[i]][k-1] 因为这里本来是个三维数组的,多一个维度用来表示前i件物品.调整了循环顺序,类似01背包空间上的优化,所以倒着循环就可以利…
/* 题意: 输入一个数n代表有n种物品, 接下来输入物品的价值和物品的个数: 然后将这些物品分成A B 两份,使A B的价值尽可能相等也就是尽量分的公平一些,如果无法使A B相等,那么就使A多一些: 思路: 先计算这些物品的总价值,然后从这些物品中去一些出来,使他们的价值尽可能的接近总价值的一半, 由此可以想到用01背包的思路: 背包容量是总价值的一半,物品体积等于物品的价值:   */     #include <cstdio> #include <cstring> #incl…
it's a  dp  difficult problem 试想如果我们遇见这样一道题,: 有n道题目,每道题有一个得分v和用时t: 我们要得够w分:用时最少  怎么做?? 这是一个裸奔的01背包 如果多一个规则, 每道题有一个开始时间,也就是开始做该题的时间不得少于一个时间st 现在怎么做? 我们应该把问题按照开始时间进行排序. 为什么? 用 st1 t1 与 st2 t2 来看 如果st1<st2 如果事情1先开始 那么所用时间ti1=st1+t1+(wait_time)t2 如果事情2先开…
标题的含义给出N问题.和概率P,然后给予相应的分数为每个问题x(每个问题只有两种选择,纠正错误). 两个人来回答.一个人是随机选择的答案,问:还有一个人的至少一些点的能力有保证P概率不会失败. 01背包,最大分数为40000,01背包处理,记录这40000个分数出现的次数 然后从小分数遍历一边就可以 #include "stdio.h" #include "string.h" #include "math.h" __int64 hash[4001…
题意 给出物品种类,物品单价,每种物品的数量,尽可能把其分成价值相等的两部分. 思路 背包的思路显然是用一半总价值当作背包容量. 生成函数则是构造形如$1+x^{w[i]}+x^{2*w[i]}+...+x^{num[i]*w[i]}$的多项式,找到离$sum/2$最近的就完事. 代码 #include <bits/stdc++.h> #define DBG(x) cerr << #x << " = " << x << end…
转载自:http://www.cppblog.com/dango/archive/2010/08/26/124881.aspx 貌似是01背包的强化版.但是感觉这样写好理解些.就是01背包拓展了.…
题目链接 题意:给出n个物品的价值v,每个物品有m个,设总价值为sum,求a,b.a+b=sum,且a尽可能接近b,a>=b. 题解:01背包. #include <bits/stdc++.h> using namespace std; ],dp[],n,v,m; int main() { ) { memset(dp,,sizeof(dp)); ,cnt=; ;i<n;i++) { scanf("%d%d",&v,&m); sum+=v*m; w…