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. pscp命令详解

    注意:只能在winds下执行 环境准备 1.先下载pscp软件,这里是我的云盘地址: 链接:https://pan.baidu.com/s/1mkzRMv-aosC94KbMcMea9w 提取码:k0 ...

  2. F#周报2019年第46期

    新闻 使用Pulumi和.NET Core创建现代云应用 宣告.NET Core 3.1预览版3 ML.NET模型构建器升级 .NET Framework修复工具 Mac上的Visual Studio ...

  3. Tomcat开启关闭常见问题

    启动 bin/startup.bat ,双击运行该文件即可 访问:浏览器输入: http://localhost:8080 回车访问自己 http://别人的ip:8080 访问别人 可能出现的问题: ...

  4. PHP-PSR 现代PHPer的开发规范

    PSR是PHP Standards Recommendation的简称,意为PHP推荐标准.要想了解PSR,首先得知道制定这一标准的人/组织是谁————PHP-FIG. PHP-FIG PHP-FIG ...

  5. C# 彻底搞懂async/await

    前言 Talk is cheap, Show you the code first! private void button1_Click(object sender, EventArgs e) { ...

  6. x86汇编分页模式实验 --《ORANGE'S一个操作系统的实现》中 pmtest8.asm解析

    序言(废话) : 在看书的过程中发现一开始不是很能理解pmtest8的目的,以及书上说得很抽象..于是在自己阅读过源代码后,将一些自己的心得写在这里. 正文 : 讲解顺序依然按照书上贴代码的顺序来.但 ...

  7. 【01】主函数main

    java和C#非常相似,它们大部分的语法是一样的,但尽管如此,也有一些地方是不同的. 为了更好地学习java或C#,有必要分清它们两者到底在哪里不同. 首先,我们将探讨主函数main. java的主函 ...

  8. MySQL 支持 emoji 图标存储

    在MySLQ中 UPDATA 和 INSERT 数据的时候,如果数据上面带有emoji图标,例如:?.?.? 很容易更新或者插入不成功,导致报错. 1 2 Error: ER_TRUNCATED_WR ...

  9. Vue.js大屏数字滚动翻转效果

    ================================ 大屏数字滚动翻转效果来源于最近工作中element后台管理页面一张大屏的UI图,该UI图上有一个模块需要有数字往上翻动的效果,以下是最 ...

  10. k8s 获取 Pod ip 添加到环境变量

    0x00 事件 有一个需要将 Pod 自身的 ip 地址添加到环境变量的需求,可以在 yaml 文件的 env 中这样设置: env: - name: POD_OWN_IP_ADDRESS value ...