poj 1742 coins_多重背包】的更多相关文章

题意:给你N个种硬币,价值和数量,知道手表不大于m,问能组成(1~m)的价格有多少种情况 套套上次那题的模板直接就行了,http://blog.csdn.net/neng18/article/details/17060539 #include <iostream> #include<cstring> #include<cstdio> using namespace std; #define MAXV 150 #define MAXM 100050 int cash,n,…
Description People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some coins.He decided to buy a very nice watch in a nearby shop. He wanted to pay the exact pri…
Coins Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 28448   Accepted: 9645 Description People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some…
ps:原来用新浪,可是代码的排版不是很好,所以用博客园啦,先容许我把从八月份开始的代码搬过来,从这里重新出发,希望这里可以一直见证我的成长. Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12337    Accepted Submission(s): 4925 Problem Description Whuacmers use coi…
多重背包模板- #include <stdio.h> #include <string.h> int a[7]; int f[100005]; int v, k; void ZeroOnePack(int cost, int weight) { for (int i = v; i >= cost; i--) if (f[i - cost] + weight > f[i]) f[i] = f[i - cost] + weight; } void CompletePack(…
题意: k个块,给出每个块的高度hi,数量ci,不能超过的高度: 求这些块可以组成的最大高度一个. 思路: 大致可看这个题是一个背包,背包的承重是高度. 对于每个物品,有他的价值是高度,还有限定的数量,看到这里就是一个多重背包, 然后对于每个物品还有一个限制是对于他的特定高度,这种怎么处理其实很简单吧. dp[]应该是一个存一个高度: wa了一发,没有考虑一维的时候更新要从小到大..所以按照特定高度升序一下就好了- -好菜啊 #include<cstdio> #include<iostr…
Q: 倍增优化后, 还是有重复的元素, 怎么办 A: 假定重复的元素比较少, 不用考虑 Description Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the…
http://www.cnblogs.com/rainydays/archive/2013/03/08/2950258.html http://www.cnblogs.com/ziyi--caolu/p/3216827.html 第一种: 邻接+统计数量 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #in…
Dividing Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 63980   Accepted: 16591 Description Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbl…
http://poj.org/problem?id=1742 n个硬币,面值分别是A1...An,对应的数量分别是C1....Cn.用这些硬币组合起来能得到多少种面值不超过m的方案. 多重背包,不过这题很容易超时,用背包九讲的代码有人说行,但是我提交还是超时,后来参考别人代码加了一些优化才能过,有时间要去搞清楚多重背包的单调队列优化. #include<cstdio> #include<cstring> #include<algorithm> using namespa…