题意:给你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,value[MAXV],c[MAXV],f[MAXM],user[MAXM]; int main(){
int i,j,max;
while(scanf("%d%d",&n,&cash)&&n||cash){
for(i=1;i<=n;i++)
scanf("%d",&value[i]);
for(i=1;i<=n;i++)
scanf("%d",&c[i]);
memset(f,0,sizeof(f));
f[0]=1;
max=0; for(i=1;i<=n;i++){
memset(user,0,sizeof(user));
for(j=value[i];j<=cash;j++)
if(!f[j] && f[j-value[i]] && user[j-value[i]]+1<=c[i]){
user[j]=user[j-value[i]]+1;
f[j]=1; //j为1,即j是可取的,选出可取的最大的j就是答案
max++;
}
}
printf("%d\n",max); }
return 0;
}

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

  1. POJ 1742 Coins(多重背包, 单调队列)

    Description People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar. ...

  2. POJ 1742 Coins (多重背包)

    Coins Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 28448   Accepted: 9645 Descriptio ...

  3. coins_多重背包

    ps:原来用新浪,可是代码的排版不是很好,所以用博客园啦,先容许我把从八月份开始的代码搬过来,从这里重新出发,希望这里可以一直见证我的成长. Time Limit: 2000/1000 MS (Jav ...

  4. Hdu 1059 Dividing & Zoj 1149 & poj 1014 Dividing(多重背包)

    多重背包模板- #include <stdio.h> #include <string.h> int a[7]; int f[100005]; int v, k; void Z ...

  5. POJ 2392【多重背包】

    题意: k个块,给出每个块的高度hi,数量ci,不能超过的高度: 求这些块可以组成的最大高度一个. 思路: 大致可看这个题是一个背包,背包的承重是高度. 对于每个物品,有他的价值是高度,还有限定的数量 ...

  6. POJ 1014 Dividing(多重背包, 倍增优化)

    Q: 倍增优化后, 还是有重复的元素, 怎么办 A: 假定重复的元素比较少, 不用考虑 Description Marsha and Bill own a collection of marbles. ...

  7. poj 1276(多重背包+最接近)

    http://www.cnblogs.com/rainydays/archive/2013/03/08/2950258.html http://www.cnblogs.com/ziyi--caolu/ ...

  8. POJ 1014 Dividing 多重背包

    Dividing Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 63980   Accepted: 16591 Descri ...

  9. poj 1742 Coins (多重背包)

    http://poj.org/problem?id=1742 n个硬币,面值分别是A1...An,对应的数量分别是C1....Cn.用这些硬币组合起来能得到多少种面值不超过m的方案. 多重背包,不过这 ...

随机推荐

  1. 关于WPF中承载 ArcGIS控件。

    原文 http://www.cnblogs.com/zoe-j/archive/2011/05/18/2050208.html 之前就做过WPF的应用,之前承载的MapGIS的二次开发控件,今天写一下 ...

  2. 导入时如何定制spring-boot依赖项的版本

    spring-boot通过maven的依赖管理为我们写好了很多依赖项及其版本,我们可拿来使用.spring-boot文档介绍了两种使用方法,一是继承,二是导入. 通过<parent>继承: ...

  3. Repeated DNA Sequences 解答

    Question All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: ...

  4. iptables or netfilter

    netfilter 内部有三个表:filter .nat .mangle 每个表又有不同的操作链: 1.在filter这个防火墙功能的表中有三个chain:INPUT.FORWARD.OUTPUT. ...

  5. Unity 制作RPG小地图

    效果图: 最近公司要制作小地图,搜索网上的文章没找到有什么小实例,=.=直接上步骤: 制作小地图步骤: 1. 人物头顶有一个面板呈现人物图标 2. 有一个摄像机在主角头顶!(Target Textur ...

  6. Primes on Interval(二分 + 素数打表)

    Primes on Interval Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

  7. HDUJ 1754 I Hate It

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  8. 【错排问题】【HDU2048】神、上帝以及老天爷

    神.上帝以及老天爷 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  9. Android 关于屏幕适配

    android屏幕适配详解 官方地址:http://developer.android.com/guide/practices/screens_support.html 转自:http://www.c ...

  10. 自定义的GitLab 头像无法正常显示以及URL总是指向localhost

    解决指向localhost的问题: 编辑gitlab的配置vi /etc/gitlab/gitlab.rb,修改external_url 参数值 [Mesogene@localhost ~]$ sud ...