1648.
Journey with Knapsack
时间限制 4000 ms
内存限制 128 MB
KazaQ has a knapsack with volume $2 \cdot n$ and $n$ kinds of food, where the $i$-th food's volume is $i$ and the number of it is $a_i$ $(1 \leq i \leq n)$ meaning that the number of the $i$-th food that KazaQ would like to store into the knapsack is no more than $a_i$, otherwise he would feel sick. KazaQ has a unique taste, therefore all the $a_i$ are distinct.
KazaQ plans to make a journey but after that he needs to store some food and one piece of equipment into the knapsack. He has $m$ pieces of equipment, of which the $i$-th piece's volume is $b_i$ $(1 \leq i \leq n)$. Notice that volumes of different pieces may be the same.
Assuming that two plans are distinct if and only if they contain different pieces of equipment or there exists at least one integer $k$ $(1 \leq k \leq n)$ satisfying the number of the $k$-th food to store into the knapsack in this two plans are different, KazaQ is intend to know what is the total number of distinct plans for storing one piece of equipment and some food into the knapsack fully. Can you help him?
The answer may be very large, so you only need to give the value of the answer modulo $10^9 + 7$.
输入数据
输出数据
For each test case, output "Case #$x$: $y$" in one line (without quotes), where $x$ indicates the case number starting from $1$ and $y$ denotes the answer of corresponding case.
样例输入
复制
1 1
1
1
2 2
1 2
3 4
3 3
1 2 3
2 3 3
· \n
\n
\n
· \n
· \n
· \n
· \n
· · \n
· · \n
样例输出
复制
Case #1: 1
Case #2: 2
Case #3: 6
· · \n
· · \n
· · \n