ACdream原创群赛(13)のwuyiqi退役专场 C True love
True love
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
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]]&×[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的更多相关文章
- ACdream原创群赛(18)のAK's dream题解
只做了4题水题ADGI A题需要注意的就是“[...]”的输出了,何时输出,何时不输出. #include <stdio.h> int main() { int n, cur, d; ; ...
- ACdream原创群赛__15
这场感觉题目确实还算可以,不过,说好的每题10s效果上却不理想.这个时限还算比较紧.因为时间不是按绝对的多出几秒来计算,而是几倍来计算的. 比赛做的不好,后面又去做了一下. A:典型的数位DP,一直坑 ...
- dp --- acdream原创群赛(16) --- B - Apple
<传送门> B - Apple Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Other ...
- ACdream区域赛指导赛之专题赛系列(1)の数学专场
Contest : ACdream区域赛指导赛之专题赛系列(1)の数学专场 A:EOF女神的相反数 题意:n(<=10^18)的数转化成2进制.翻转后(去掉前导零)输出十进制 思路:water ...
- “玲珑杯”线上赛 Round #17 河南专场
闲来无事呆在寝室打打题,没有想到还有中奖这种操作,超开心的 玲珑杯”线上赛 Round #17 河南专场 Start Time:2017-06-24 12:00:00 End Time:2017-06 ...
- NOIP2017提高组 模拟赛13(总结)
NOIP2017提高组 模拟赛13(总结) 第一题 函数 [题目描述] [输入格式] 三个整数. 1≤t<10^9+7,2≤l≤r≤5*10^6 [输出格式] 一个整数. [输出样例] 2 2 ...
- ACdream群赛1112(Alice and Bob)
题意:http://acdream.info/problem?pid=1112 Problem Description Here is Alice and Bob again ! Alice and ...
- 第六届acm省赛总结(退役贴)
前言: 这是我的退役贴,之前发到了空间里,突然想到也要在博客里发一篇,虽然我很弱,但是要离开了还是有些感触,写出来和大家分享一下,希望不要见笑.回来看看,这里也好久没有更新了,这一年确实有些懈怠,解题 ...
- k8s升级,HA集群1.12.0~HA集群1.13.2
k8s升级,此次升级是1.12.0 至1.13.2 准备 # 首先升级master节点的基础组件kubeadm.kubelet.kubectl apt policy kubeadm 找到相应的版本,如 ...
随机推荐
- 2019西安多校联训 Day5
T1 光哥为了不让某初二奆佬恶心到我们而留下的火种 (貌似没这题平均分就100-了) 思路:就一横一竖让后就gztopa嘛 #include <bits/stdc++.h> using n ...
- ssh服务使用介绍二
老司机开车了 快上车 上文提到当我们使用ssh远程链接主机的时候,会出现询问的提示,如果我们链接的机器多了,一遍一遍的输入是不是很麻烦?怎么解决如下 vim /etc/ssh/ssh_config 如 ...
- 如何用纯 CSS 为母亲节创作一颗像素画风格的爱心
效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/LmrZVX 可交互视频教 ...
- vue 项目部署
vue项目部署到PHP项目 入口目录 vue项目打包后, 是一个单文件html 我们只需要把打包后的文件夹放在php项目的public下面 访问 xxx.com/h5/index.html 就可以访问 ...
- Python-集合数据类型内置方法
集合内置方法(必考) 用途:用于关系运算的集合体,由于集合内的元素无序且集合元素不可重复,因此集合可以去重,但是去重后的集合会打乱原来元素的顺序. 定义方式:{}内用逗号隔开多个元素,元素只能是不可变 ...
- IDEA+Tomcat热部署自动编译
https://www.cnblogs.com/1024zy/p/6344000.html 之前太傻瓜了,一直以为用了IDEA改了类或者js的时候全都要手动构建发布,其实不用,IDEA这么好的工具怎么 ...
- Python补充--Python内置函数清单
Python内置函数 Python内置(built-in)函数随着python解释器的运行而创建.在Python的程序中,你可以随时调用这些函数,不需要定义.最常见的内置函数是: print(&quo ...
- 65.什么是IOC?【从零开始学Spring Boot】
[从零开始学习Spirng Boot-常见异常汇总] 这个小节吧,是无意当中看了一篇文章,觉得介绍的特别好,引用到我的博客中,让大家也乐下.那么他是怎么解说IOC的呢?看如下: 套用好莱坞的一句名言就 ...
- ubuntu使用git时,终端不显示git分支。
1:问题描述: 在Windows环境下习惯使用git bash操作git分支,最近学习linux环境,发现linux环境终端不显示git分支,相关现象如下: 期望效果是: 我的linux环境 ...
- 搭建nexus私服,无法下载相关jar包,报错Repository proxy-mode is BLOCKED_AUTO
在搭建nexus私服的时候,之前没直接用来下载maven的相关插件jar包,一直可以使用, 结果今天要编译hadoop的时候,在linux上新用maven就报错了,无法下载maven的相关插件(如下) ...