hdu(1171)多重背包】的更多相关文章

Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32578    Accepted Submission(s): 11377 Problem Description Nowadays, we all know that Computer College is the biggest department…
题意:给出价值和数量,求能分开的最近的两个总价值,例如10,20*2,30,分开就是40,40 链接:点我 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map> using namespace std; #define MOD 100000…
Food Problem Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1243    Accepted Submission(s): 368 Problem Description Few days before a game of orienteering, Bell came to a mathematician to sol…
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19108    Accepted Submission(s): 6707 Problem Description Nowadays, 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…
题目链接:hdu1171 思路:将多重背包转为成完全背包和01背包问题,转化为01背包是用二进制思想,即件数amount用分解成若干个件数的集合,这里面数字可以组合成任意小于等于amount的件数 比如:7的二进制 7 = 111 它可以分解成 001 010 100 这三个数可以组合成任意小于等于7 的数,而且每种组合都会得到不同的数: 如果13 = 1101 则分解为 0001 0010 0100 0110 前三个数字可以组合成7以内任意一个数,加上 0110 = 6 可以组合成任意一个大于…
http://acm.hdu.edu.cn/showproblem.php?pid=2191 New~ 欢迎“热爱编程”的高考少年——报考杭州电子科技大学计算机学院关于2015年杭电ACM暑期集训队的选拔 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17930    Accepted…
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)Total Submission(s): 28483    Accepted Submission(s): 10027 Problem Description Nowadays, we all know…
Big Event in HDU   Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1139 Accepted Submission(s): 444 Problem Description Nowadays, we all know that Computer College is the biggest department in HD…
这里;http://acm.hdu.edu.cn/showproblem.php?pid=1059 题意是有价值分别为1,2,3,4,5,6的商品各若干个,给出每种商品的数量,问是否能够分成价值相等的两份. 联想到多重背包,稍微用二进制优化一下.(最近身体不适,压力山大啊) #include<iostream> #include<cstring> #include<cstdio> #define inf 70000 using namespace std; int dp…
HDU 1114 Piggy-Bank 完全背包问题. 想想我们01背包是逆序遍历是为了保证什么? 保证每件物品只有两种状态,取或者不取.那么正序遍历呢? 这不就正好满足完全背包的条件了吗 means:给出小猪钱罐的重量和装满钱后的重量,然后是几组数据,每组数据包括每种钱币的价值与重量要求出装满钱罐时的最小价值 #include<cstdio> #include<cstring> #include<cmath> #include<iostream> usin…
题意:价值分别为1,2,3,4,5,6的物品个数分别为a[1],a[2],a[3],a[4],a[5],a[6],问能不能分成两堆价值相等的. 解法:转化成多重背包 #include<stdio.h> #include<string.h> #include<algorithm> #include<iostream> using namespace std; ]; ]; int nValue; //0-1背包,代价为cost,获得的价值为weight void…
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22553    Accepted Submission(s): 9524 Problem Description 急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市…
Dividing Sample Input 1 0 1 2 0 0 价值为1,2,3,4,5,6的物品数目分别为 1 0 1 2 0 0,求能否将这些物品按价值分为两堆,转化为多重背包.1 0 0 0 1 10 0 0 0 0 0   Sample Output   Collection #1: Can't be divided.   Collection #2: Can be divided. #include <algorithm> #include <iostream> #i…
Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10632    Accepted Submission(s): 4230 Problem Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One…
Problem Description 急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买.请问:你用有限的资金最多能采购多少公斤粮食呢? 后记:人生是一个充满了变数的生命过程,天灾.人祸.病痛是我们生命历程中不可预知的威胁.月有阴晴圆缺,人有旦夕祸福,未来对于我们而言是一个未知数.那么,我们要做的就应该是珍惜现在,感恩生活——感谢父母,他们给予我们生命,抚养…
给出N种钱币和M 给出N种钱币的面值和个数 NPC拿着这N些钱币去买价值M的物品,能够多付.然后被找零,找零的钱也为这些面值.但没有数量限制 问最少经手的钱币数量 对于NPC做一个付款多重背包 然后对于找零做一个全然背包 ans=Min(dp1[i]+dp2[i-m],ans); #include "stdio.h" #include "string.h" int n,m; int dp1[20010],dp2[20010],c[20010],v[20010]; v…
题目大意: 给定一堆1,2,5价值的硬币,给定三个数表示3种价值硬币的数量,任意取,找到一个最小的数无法取到 总价值为M = v[i]*w[i](0<=i<3) 那么在最坏情况下M个数都能取到 , M+1必然取不到 所以给M+1个背包,往里面塞东西,最后由前往后检测,找到第一个无法取满的背包的体积 这道题目里,每一种物品的v*w必然小于M+1,所以不出现完全背包的情况,全部采用多重背包转化为0-1背包解决问题即可 #include <cstdio> #include <cst…
在杭电上测试了下 这里的状态转移方程有两个.,. 现在有价值val[1],val[2],…val[n]的n种硬币, 它们的数量分别为num[i]个. 然后给你一个m, 问你区间[1,m]内的所有数目, 由之前n种硬币来构造(即选取某些硬币使得这些硬币的价值和等于[1,m]区间的特定数), 最多能构造出这m个数中的多少个? 初始化: dp为全0,且 dp[0][0]==1. 对于每种硬币, 我们有两种可能的方式处理://重点 多重包的两种转化 1.   Val[i]*num[i]>= m时, 对当…
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 i…
http://acm.hdu.edu.cn/showproblem.php?pid=2844 题意: 有n个硬币,知道其价值A1.....An.数量C1...Cn.问在1到m价值之间,最多能组成多少种价值. 思路: dp[i]表示i价值能够组成的最大种数. New~ 欢迎“热爱编程”的高考少年——报考杭州电子科技大学计算机学院关于2015年杭电ACM暑期集训队的选拔 Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 327…
http://acm.hdu.edu.cn/showproblem.php?pid=1171 基础的01背包,求出总值sum,背包体积即为sum/2 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ],bao[]; int main() { int sum,i,j,k,m,n,a; while(scanf("%d",&n)!=EOF)…
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 2191 Description 急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买. 请问:你用有…
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29234    Accepted Submission(s): 10275 Problem Description Nowadays, we all know that Computer College is the biggest department…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2191 实现代码: #include<bits/stdc++.h> using namespace std; ; int dp[M]; struct node{ int w,v; }lis[M]; int main() { int t,n,m,p,h,c,idx; cin>>t; while(t--){ idx = ; cin>>n>>m; memset(dp,,si…
思路:把价值看做体积,而价值的大小还是其本身,那么只需判断1-m中的每个状态最大是否为自己,是就+1: #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #define Maxn 100010 #define Max(a,b) (a)>(b)?(a):(b) using namespace std; ],v[]; struct Que{ int pos,v…
思路: 这个方法要看<浅谈几类背包问题>这篇论文. #include"stdio.h" #define Max(a,b) (a)>(b)?(a):(b) ],k[]; int main() { ; ],&k[],&k[],&k[],&k[],&k[])!=EOF,k[]|k[]|k[]|k[]|k[]|k[]) { ;i<=;i++) f[i]=; ]+k[]*+k[]*+k[]*+k[]*+k[]*; sum%=; ;…
//http://www.cnblogs.com/devil-91/archive/2012/05/16/2502710.html #include<stdio.h> #define N 110000 #include<string.h> int dp[N]; int main() { int n,m,i,j,a[N],b[N],k,h; while(scanf("%d%d",&n,&m),n||m) { memset(dp,0,sizeof(d…
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…
题目链接: 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…