ACM-ICPC 2018 焦作赛区网络预赛 K题 Transport Ship
There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1. How many different schemes there are if you want to use these ships to transport cargo with a total weight of SS?
It is required that each ship must be full-filled. Two schemes are considered to be the same if they use the same kinds of ships and the same number for each kind.
Input
The first line contains an integer T(1 \le T \le 20)T(1≤T≤20), which is the number of test cases.
For each test case:
The first line contains two integers: N(1 \le N \le 20), Q(1 \le Q \le 10000)N(1≤N≤20),Q(1≤Q≤10000), representing the number of kinds of ships and the number of queries.
For the next NN lines, each line contains two integers: V[i](1 \le V[i] \le 20), C[i](1 \le C[i] \le 20)V[i](1≤V[i]≤20),C[i](1≤C[i]≤20), representing the weight the i^{th}ith kind of ship can carry, and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1.
For the next QQ lines, each line contains a single integer: S(1 \le S \le 10000)S(1≤S≤10000), representing the queried weight.
Output
For each query, output one line containing a single integer which represents the number of schemes for arranging ships. Since the answer may be very large, output the answer modulo 10000000071000000007.
样例输入复制
1
1 2
2 1
1
2
样例输出复制
0
1
题目来源
题解:二进制求和+DP
参考代码:
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<bitset>
#define INF 0x3f3f3f3f
#define clr(x, y) memset(x, y, sizeof(x))
#define mod 1000000007
using namespace std;
typedef long long LL;
const int maxn=;
const int maxm=;
int v[maxn],c[maxn];
LL dp[maxm]; int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n, q;
scanf("%d%d", &n, &q);
memset(dp, , sizeof(dp));
dp[] = ;
for(int i = ; i <= n; i++)
{
scanf("%d%d", &v[i], &c[i]);
LL cur = ;
for(int j = ; j <= c[i]; j++)
{
for(int k = ; k >= cur * v[i]; k--)
dp[k] = (dp[k] + dp[k - cur * v[i]]) % mod;
cur<<=;
}
}
for(int i = ; i <= q; i++)
{
int s;
scanf("%d", &s);
printf("%lld\n", dp[s]);
}
}
return ;
}
ACM-ICPC 2018 焦作赛区网络预赛 K题 Transport Ship的更多相关文章
- ACM-ICPC 2018 焦作赛区网络预赛J题 Participate in E-sports
Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know ...
- ACM-ICPC 2018 焦作赛区网络预赛 L 题 Poor God Water
God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him t ...
- ACM-ICPC 2018 焦作赛区网络预赛 B题 Mathematical Curse
A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics ...
- ACM-ICPC 2018 焦作赛区网络预赛 I题 Save the Room
Bob is a sorcerer. He lives in a cuboid room which has a length of AA, a width of BB and a height of ...
- ACM-ICPC 2018 焦作赛区网络预赛 H题 String and Times(SAM)
Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring won ...
- ACM-ICPC 2018 焦作赛区网络预赛 G题 Give Candies
There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more inte ...
- ACM-ICPC 2018 焦作赛区网络预赛 K Transport Ship (多重背包)
https://nanti.jisuanke.com/t/31720 题意 t组样例,n种船只,q个询问,接下来n行给你每种船只的信息:v[i]表示这个船只的载重,c[i]表示这种船只有2^(c[i] ...
- ACM-ICPC 2018 焦作赛区网络预赛 K. Transport Ship(DP)
题目链接:https://nanti.jisuanke.com/t/31720 题意:有n种飞船,每种飞船有(1 << c)- 1 艘,容量为 k[i] ,q 次询问,每次询问选若干艘飞 ...
- ACM-ICPC 2018 沈阳赛区网络预赛 K题
题目链接: https://nanti.jisuanke.com/t/31452 AC代码(看到不好推的定理就先打表!!!!): #include<bits/stdc++.h> using ...
随机推荐
- fpm打包神奇rpm包升级python2.7.16
fpm打包神器参考文档:https://www.cnblogs.com/flintlovesam/p/6594635.html FPM的安装:安装ruby环境和gem命令: yum -y instal ...
- PHP导出成PDF你用哪个插件
准备工作 首先查询了相关的类库,有FPDF,zendPDF,TcPDF等等.首先看了下先选择了FPDF,可以说除了中文字符以外没有什么问题,中文乱码而且看了下最新版本没有很好的解决方案,所以只能放弃. ...
- Vue躬行记(9)——Vuex
Vuex是一个专为Vue.js设计的状态管理库,适用于多组件共享状态的场景.Vuex能集中式的存储和维护所有组件的状态,并提供相关规则保证状态的独立性.正确性和可预测性,这不仅让调试变得可追踪,还让代 ...
- java编程思想第四版第八章总结
1. 多态的含义 面向对象的三大基本特征: 封装,继承,多态. 多态是干什么的? 多态将做什么和怎么做分离开.从另一个角度将接口是实现类分离开. 多态的作用 消除类型之间耦合的关系 使用多态的好处? ...
- PhpStudy BackDoor2019 深度分析
笔者<Qftm>原文发布<合天>:https://mp.weixin.qq.com/s?__biz=MjM5MTYxNjQxOA==&mid=2652852661&am ...
- 详解Redis RDB持久化、AOF持久化
1.持久化 1.1 持久化简介 持久化(Persistence),持久化是将程序数据在持久状态和瞬时状态间转换的机制,即把数据(如内存中的对象)保存到可永久保存的存储设备中(如磁盘). 1.2 red ...
- 从cocos2dx源代码看android和iOS跨平台那些事
cocos2dx一个跨移动(平板)平台的游戏引擎,支持2d和3d,基于c/c++,网上介绍多在此不详叙.我们本篇关心的是跨平台那些事,自然而然就找到platform目录.好家伙,支持的操作平台还真不少 ...
- [apue] FIFO:不是文件的文件
众所周知,FIFO中文译为命名管道,是PIPE的升级版.而PIPE是管道,系统提供的一种进程间通讯方式,FIFO与PIPE有以下方面不同: 1) FIFO需要先在文件系统创建(mkfifo),之后使用 ...
- Fragment的生命周期(与Activity的对比)
Fragment必须是依存与Activity而存在的,因此Activity的生命周期会直接影响到Fragment的生命周期.官网这张图很好的说明了两者生命周期的关系: 可以看到Fragment比Act ...
- python 面向对象的基本概念(未完待续)
面向对象编程简称OOP(Object-oriented-programming),是一种程序设计思想. 面向过程编程(如C语言)指一件事该怎么做,面向对象编程(如Java.python)指一件事该让谁 ...