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

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

题解:二进制求和+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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. ACM-ICPC 2018 焦作赛区网络预赛 B题 Mathematical Curse

    A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics ...

  4. 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 ...

  5. 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 ...

  6. ACM-ICPC 2018 焦作赛区网络预赛 G题 Give Candies

    There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more inte ...

  7. ACM-ICPC 2018 焦作赛区网络预赛 K Transport Ship (多重背包)

    https://nanti.jisuanke.com/t/31720 题意 t组样例,n种船只,q个询问,接下来n行给你每种船只的信息:v[i]表示这个船只的载重,c[i]表示这种船只有2^(c[i] ...

  8. ACM-ICPC 2018 焦作赛区网络预赛 K. Transport Ship(DP)

    题目链接:https://nanti.jisuanke.com/t/31720 题意:有n种飞船,每种飞船有(1 << c)- 1  艘,容量为 k[i] ,q 次询问,每次询问选若干艘飞 ...

  9. ACM-ICPC 2018 沈阳赛区网络预赛 K题

    题目链接: https://nanti.jisuanke.com/t/31452 AC代码(看到不好推的定理就先打表!!!!): #include<bits/stdc++.h> using ...

随机推荐

  1. IDEA升级,提示"Connection Error Failed to prepare an update"

    问题来源: 之前修改了IDEA的默认配置文件路径,然后升级新版本时就无法升级,提示"Failed to prepare an update Temp directory inside ins ...

  2. 使用 vue-element-admin 动态路由渲染

    附上:vue-element-admin 官方文档 vue-element-admin https://panjiachen.github.io/vue-element-admin-site/zh/g ...

  3. jsp页面不乱码,外部引用的js弹出对话框乱码

    今天在做一个课程设计的时候,写到一个界面注册,在用js判断数据的正确性时,碰到了一个js弹出框的乱码问题.在网上找寻了很久,也找了很多博客看,但是发现怎么样都不能解决我的问题,下面给出几个比较经典的解 ...

  4. MySQL数据库root账户密码忘记两种处理方法(保有效)

    方法1: 1.停止MySQL服务 # kill `cat /var/run/mysqld/mysqld.pid` 或者 # pkill mysqld 2.创建一个密码赋值语句的文本文件 # vi my ...

  5. JS如何在不给新空间的情况下给数组去重?

    1.先排序,在让相邻元素对比去重 const nums = [3, 1, 1, 5, 2, 3, 4, 3, 5, 5, 6, 4, 6, 6, 6]; Array.prototype.arrayNo ...

  6. 线程同步&线程池

    线程同步&线程池 线程同步 线程不同步会出现的问题: 当多个线程操作同一资源时,会出现重复操作和和操作不存在的资源的问题,为了规避这一问题就需要线程的同步操作来实现资源的共同使用. 线程同步: ...

  7. 关闭Eslint检查

    Eslint是一个JavaScript的校验插件,通常用来校验语法或代码的书写风格.不过有点过于严格,通常缩减不同也会报错... 这会影响工作效率啊,最好就是在创建项目的时候不要ESlint(选择No ...

  8. Flex调用本地文件分析

    最近在用Flex做一个相册的功能,因为图片数据很多,所以想调用本地文件的方式做. 但是B/S的缘故,很多安全上的限制给我造成了不小的麻烦,把我这个小菜鸟弄的晕头转向. 第一,刚开始,查了很多资料发现都 ...

  9. JavaScript笔记八

    1.原型(prototype) - 创建一个函数以后,解析器都会默认在函数中添加一个数prototype prototype属性指向的是一个对象,这个对象我们称为原型对象. - 当函数作为构造函数使用 ...

  10. TensorBoard:可视化学习

    数据序列化 TensorBoard 通过读取 TensorFlow 的事件文件来运行.TensorFlow 的事件文件包括了你会在 TensorFlow 运行中涉及到的主要数据.下面是 TensorB ...