HDU 2844 Coins 多重背包

本文深入探讨了编程领域的核心技术,包括数据结构、算法、版本控制等,为开发者提供全面的技术指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Coins

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10236    Accepted Submission(s): 4083


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
 

Recommend
gaojie   |   We have carefully selected several similar problems for you:   2159  2955  1203  1171  1864 
套模板
ACcode:
#pragma warning(disable:4786)//使命名长度不受限制
#pragma comment(linker, "/STACK:102400000,102400000")//手工开栈
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d%d",&x,&y)
#define rds(x) scanf("%s",x)
#define rdc(x) scanf("%c",&x)
#define ll long long int
#define maxn 100000+10
#define mod 1000000007
#define INF 0x3f3f3f3f //int 最大值
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i)
#define MT(x,i) memset(x,i,sizeof(x))
#define PI  acos(-1.0)
#define E  exp(1)
using namespace std;
int Max(int a,int b){return a>b?a:b;}
int c[maxn],w[maxn],num[maxn],f[maxn];///c:费用 w:价值 num:
int V,n,m;
void ZeroOnePack(int c,int w){
    for(int v=V;v>=c;v--)
        f[v]=Max(f[v],f[v-c]+w);
}
void CompletePack(int c,int w){
    for(int v=c;v<=V;v++)
        f[v]=Max(f[v],f[v-c]+w);
}
void MultiplePack(int c,int w,int nl){
    if(c*nl>=V)
        CompletePack(c,w);
    else {
        int k=1;
        while(k<nl){
            ZeroOnePack(k*c,k*w);
            nl-=k;k<<=1;
        }
        ZeroOnePack(nl*c,nl*w);
    }
}
int main(){
    while(rd2(n,m),(n+m)){
        V=m;MT(f,0);
        FOR(i,1,n)rd(c[i]);
        FOR(i,1,n)rd(num[i]);
        FOR(i,1,n)
        MultiplePack(c[i],c[i],num[i]);
        int cc=0;
        FOR(i,1,m)if(i==f[i])cc++;
        printf("%d\n",cc);
    }
    return 0;
}
/*
3 10
1 2 4 2 1 1
2 5
1 4 2 1
*/

 
资源下载链接为: https://pan.quark.cn/s/22ca96b7bd39 在C#开发中,Windows Media Player控件是集成音频和视频播放功能的强大工具。本文将介绍如何在C#中实现不同的播放模式,如随机播放、列表循环和单曲循环,这些功能在多媒体应用中十分常见 。 要使用Windows Media Player控件,首先需要将其添加到C#项目中。在Visual Studio中,可以通过在工具箱中搜索“Windows Media Player”,并将其拖放到窗体上完成 。接着,设置控件的基本属性,如URL,以指定要播放的媒体文件 。 随机播放模式会在一首歌曲播放结束后,随机选择播放列表中的下一首歌曲。可以通过创建一个包含所有歌曲URL的数组,并利用Random类生成随机索引来实现。例如: 列表循环模式会在一首歌曲播放结束后,自动从播放列表的开头重新开始播放。实现方法是检测到播放结束后,将URL重置为列表的第一个元素: 单曲循环模式则是在一首歌曲播放结束后,重新播放当前歌曲。可以通过将播放器的当前播放位置重置为0并重新播放来实现: 以上代码均需在windowsMediaPlayer1_PlayStateChange事件处理器中实现,该事件会在播放器的播放状态改变时触发 。需要注意的是,这些示例假设已正确引用了WMPLib命名空间,并且Windows Media Player控件的ID为“windowsMediaPlayer” 。 在实际应用中,除了实现播放模式外,还可能需要考虑错误处理、用户界面更新等因素。为了使播放列表更具动态性,可以考虑从数据库或XML文件加载歌曲信息,而不是硬编码在代码中,从而提升用户体验 。通过这些方法,可以在C#中灵活实现Windows Media Player的各种播放模式,满足不同多媒体应用场景的需求 。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值