博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 2844 Coins
阅读量:6207 次
发布时间:2019-06-21

本文共 1802 字,大约阅读时间需要 6 分钟。

Coins

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5407 Accepted Submission(s): 2230
Problem Description
Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in a nearby shop. He wanted to pay the exact price(without change) and he known the price would not more than m.But he didn't know the exact price of the watch.
You are to write a program which reads n,m,A1,A2,A3...An and C1,C2,C3...Cn corresponding to the number of Tony's coins of value A1,A2,A3...An then calculate how many prices(form 1 to m) Tony can pay use these coins.
Input
The input contains several test cases. The first line of each test case contains two integers n(1 ≤ n ≤ 100),m(m ≤ 100000).The second line contains 2n integers, denoting A1,A2,A3...An,C1,C2,C3...Cn (1 ≤ Ai ≤ 100000,1 ≤ Ci ≤ 1000). The last test case is followed by two zeros.
Output
For each test case output the answer on a single line.
Sample Input
3 10
1 2 4 2 1 1
2 5
1 4 2 1
0 0
Sample Output
8
4
Source
2009 Multi-University Training Contest 3 - Host by WHU
Recommend
gaojie

//593MS    640K    1071 B    C++//多重背包小优化算法//装换成01+完全,时间复杂度降低才能过 #include
#include
int dp[100005],c[105],v[105];int n,m;int Max(int a,int b){ return a>b?a:b;}void _01pack(int cost,int weight){ for(int i=m;i>=weight;i--) dp[i]=Max(dp[i],dp[i-weight]+cost);} void compack(int cost,int weight){ for(int i=weight;i<=m;i++) dp[i]=Max(dp[i],dp[i-weight]+cost); }void mulpack(int cost,int weight,int count){ if(count*cost>=m){ compack(cost,weight);return; } int k=1; while(k

 

转载于:https://www.cnblogs.com/GO-NO-1/articles/3334226.html

你可能感兴趣的文章
Redis-3.2主从复制与集群搭建 推荐
查看>>
随便说说:在ASP.NET应用程序中上传文件
查看>>
【jQuery Demo】图片由下至上逐渐显示
查看>>
在.NET中使用SMTP发送邮件
查看>>
Unity Camera的两种模式
查看>>
3.5. Ticket
查看>>
越狱第一至五季/全集迅雷下载
查看>>
从Mysql slave system lock延迟说开去
查看>>
归并排序
查看>>
RecyclerView的下拉刷新和加载更多 动画
查看>>
ABAP常见面试问题
查看>>
程序猿是如何解决SQLServer占CPU100%的
查看>>
web.xml
查看>>
HBase-1.2.4LruBlockCache实现分析(一)
查看>>
SDN交换机在云计算网络中的应用场景
查看>>
革新以太网交换机架构 全光网络的风刮进园区
查看>>
物联网商机迸发 LPWAN芯片现身 本文转自d1net(转载)
查看>>
【eclipse转idea的第一天】配置idea
查看>>
error: Refusing toundefine while domain managed save image exists
查看>>
wordpress在新窗口打开留言者链接
查看>>