True love

Time Limit: 4000/2000 MS (Java/Others)     Memory Limit:128000/64000 KB (Java/Others)

Problem Description

Is there true love in the world?maybe or not, god knows! We know there are some complex relationships between ds and cxlove, they fell into love when they were rookies in acm,.

Now It's the season of graduation, it's also a season for lovers to say good-bye.But, ds and cxlove don't believe this. They want to show their true love and they plan to go out for a trip. But you know ds is a chihuo, he
has a lot of snacks, now he wants to know how many different volumes he can take with a bag of a certain capacity.

Input

First line there is a t. represent the test cases.

Each test case begins with two integers n, cap 

(1 <= n <= 100, 0 <= cap <= 100000).

the next line contains n integers denoting the volume of the snacks.

a[1], a[2], a[3]...a[n];

1 <= a[i] <= 100000

the last line contains n integers denoting the number of the corresponding snack.

b[1], b[2], b[3]...b[n];

1 <= b[i] <= 1000

Output

please look at the Sample Output

Sample Input

2
2 10
1 2
1 1 2 2
1 2
1 1

Sample Output

Case 1: 3
Case 2: 2

n*m背包。貌似第一次做这样的背包题。。。

。,思想还是非常easy懂的。

AC代码例如以下:

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int n,t,cap;
int i,j;
int a[105],b[105];
int dp[100005],times[100005];
int sum,cont=0;
scanf("%d",&t);
while(t--)
{
memset(dp,0,sizeof dp);
sum=0;cont++;
scanf("%d%d",&n,&cap);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
scanf("%d",&b[i]);
for(i=1,dp[0]=1;i<=n;i++)
{
memset(times,0,sizeof times);
for(j=a[i];j<=cap;j++)
{
if(!dp[j]&&dp[j-a[i]]&&times[j-a[i]]<b[i])//枚举添加a[i]能在已有基础上到达的数值。
{
sum++;
times[j]=times[j-a[i]]+1;
dp[j]=1;
}
}
}
printf("Case %d: %d\n",cont,sum);
} return 0;
}

ACdream原创群赛(13)のwuyiqi退役专场 C True love的更多相关文章

  1. ACdream原创群赛(18)のAK's dream题解

    只做了4题水题ADGI A题需要注意的就是“[...]”的输出了,何时输出,何时不输出. #include <stdio.h> int main() { int n, cur, d; ; ...

  2. ACdream原创群赛__15

    这场感觉题目确实还算可以,不过,说好的每题10s效果上却不理想.这个时限还算比较紧.因为时间不是按绝对的多出几秒来计算,而是几倍来计算的. 比赛做的不好,后面又去做了一下. A:典型的数位DP,一直坑 ...

  3. dp --- acdream原创群赛(16) --- B - Apple

    <传送门> B - Apple Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Other ...

  4. ACdream区域赛指导赛之专题赛系列(1)の数学专场

    Contest : ACdream区域赛指导赛之专题赛系列(1)の数学专场 A:EOF女神的相反数 题意:n(<=10^18)的数转化成2进制.翻转后(去掉前导零)输出十进制 思路:water ...

  5. “玲珑杯”线上赛 Round #17 河南专场

    闲来无事呆在寝室打打题,没有想到还有中奖这种操作,超开心的 玲珑杯”线上赛 Round #17 河南专场 Start Time:2017-06-24 12:00:00 End Time:2017-06 ...

  6. NOIP2017提高组 模拟赛13(总结)

    NOIP2017提高组 模拟赛13(总结) 第一题 函数 [题目描述] [输入格式] 三个整数. 1≤t<10^9+7,2≤l≤r≤5*10^6 [输出格式] 一个整数. [输出样例] 2 2 ...

  7. ACdream群赛1112(Alice and Bob)

    题意:http://acdream.info/problem?pid=1112 Problem Description Here  is Alice and Bob again ! Alice and ...

  8. 第六届acm省赛总结(退役贴)

    前言: 这是我的退役贴,之前发到了空间里,突然想到也要在博客里发一篇,虽然我很弱,但是要离开了还是有些感触,写出来和大家分享一下,希望不要见笑.回来看看,这里也好久没有更新了,这一年确实有些懈怠,解题 ...

  9. k8s升级,HA集群1.12.0~HA集群1.13.2

    k8s升级,此次升级是1.12.0 至1.13.2 准备 # 首先升级master节点的基础组件kubeadm.kubelet.kubectl apt policy kubeadm 找到相应的版本,如 ...

随机推荐

  1. C++之类成员的访问权限详解(一)

    概念解析 众所周知,面向对象编程语言的特征之一就是封装,不同编程语言对于封装提供的实现有所不同,但原理大体上是相同的.C++提供了三种不同程度的访问权限来实现,主要是通过public.private. ...

  2. idea Error:(65, 27) java: 未结束的字符串文字

    今天在使用IDEA的时候,出现了这个错误,原因项目文件编码不一致导致的,解决方法是: 将项目的文件编码全改成一致(UTF-8),如下图所示:

  3. django的基本操作流程

    pip   install django cd Desktop/课上代码02/ #进入到创建项目的目录   django-admin startproject 项目的名称  #创建项目   __ini ...

  4. LeetCode(57) Insert Interval

    题目 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if nece ...

  5. ajax 为 select 赋值

    html 页面<tr> <td class="dc-form-left">权限组:</td> <td class="dc-for ...

  6. 可以从CSS框架中借鉴到什么

    http://isux.tencent.com/css-framework.html http://isux.tencent.com/css-framework.html 现在很多人会使用 CSS 框 ...

  7. 【贪心】codeforces A. Heidi and Library (easy)

    http://codeforces.com/contest/802/problem/A [题意] 有一个图书馆,刚开始没有书,最多可容纳k本书:有n天,每天会有人借一本书,当天归还:如果图书馆有这个本 ...

  8. 关于srand()rand()的用法

    转自:http://baike.baidu.com/link?url=bhos65ZKp8lEq_6chSsmQv29jHrqjN_IFGVMNod6BuicQ-3oCP5VsEn3RBjXBPvA7 ...

  9. HDU 2629 Identity Card

    简单题 给出身份证号 判断住址 和出生年月 熟练字符串的操作 主要是string::substr(s, l)//s:起始位置 l长度 #include <iostream> #includ ...

  10. solr请求处理器列表

    List of Request Handlers Available The Javadocs contain a complete list of Request Handlers. Many of ...