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. 复制webp图片到word || 微信webp图片不能复制 || 如何复制webp到word

    用IE浏览器打开Alt+A 复制直接去word粘贴, 用IE浏览器打开Alt+A 复制直接去word粘贴 用IE浏览器打开Alt+A 复制直接去word粘贴 用IE浏览器打开Alt+A 复制直接去wo ...

  2. SpringCloud版本介绍和SpringBoot的兼容性

    Spring Cloud是一个由众多独立子项目组成的大型综合项目,每个子项目有不同的发行节奏,都维护着自己的发布版本号.Spring Cloud通过一个资源清单BOM(Bill of Material ...

  3. 深入Linux内核架构——进程管理和调度(上)

    如果系统只有一个处理器,那么给定时刻只有一个程序可以运行.在多处理器系统中,真正并行运行的进程数目取决于物理CPU的数目.内核和处理器建立了多任务的错觉,是通过以很短的间隔在系统运行的应用程序之间不停 ...

  4. git/github初级使用

    1.常见的github 国内最流行的php开发框架(thinkphp):https://github.com/top-think/thinkphp 全球最流行的php框架(laravel):https ...

  5. Vue如何在webpack设置代理解决跨域问题

            在开发过程中我们请求数据有时候调用的是第三方接口,此时便会遇到一个问题:跨域限制.对于跨域问题的解释就不详细叙述了,要了解的请自行百度.一般跨域问题控制台会报这个错:         ...

  6. jquery select 常用操作总结

    由于在项目各种所需,经常碰到select不种操作的要求,今天特意总结了一下,分享: jQuery获取Select选择的Text和Value: 语法解释: 1. $("#select_id&q ...

  7. spring boot学习02【如何在spring boot项目中访问jsp】

    1.配置application.properties文件 打开application.properties追加 spring.mvc.view.prefix=/WEB-ROOT/ spring.mvc ...

  8. CentOS6 CentOS7 yum安装图形界面

    CentOS6 yum安装图形界面yum groupinstall -y "Desktop" "Desktop Platform" "Desktop ...

  9. POJ3041:Asteroids【二分图匹配】

    二分图的最大匹配=最小顶点覆盖(Konig定理)=最大独立集的补集最大匹配经典的三种模型  这题就是最小顶点覆盖,顺便这题留给我的经验就是调试的时候一定要细心细心再细心对模板的各个细节都要熟!! #i ...

  10. POJ 1273 Drainage Ditches【图论,网络流】

    就是普通的网络流问题,想试试新学的dinic算法,这个算法暑假就开始看国家集训队论文了,之前一直都只用没效率的EK算法,真正学会这个算法还是开学后白书上的描述:dinic算法就是不断用BFS构建层次图 ...