201103: [AtCoder]ARC110 D - Binomial Coefficient is Fun

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $600$ points

Problem Statement

We have a sequence $A$ of $N$ non-negative integers.

Compute the sum of $\prod _{i = 1} ^N \dbinom{B_i}{A_i}$ over all sequences $B$ of $N$ non-negative integers whose sum is at most $M$, and print it modulo ($10^9 + 7$).

Here, $\dbinom{B_i}{A_i}$, the binomial coefficient, denotes the number of ways to choose $A_i$ objects from $B_i$ objects, and is $0$ when $B_i < A_i$.

Constraints

  • All values in input are integers.
  • $1 \leq N \leq 2000$
  • $1 \leq M \leq 10^9$
  • $0 \leq A_i \leq 2000$

Input

Input is given from Standard Input in the following format:

$N$ $M$
$A_1$ $A_2$ $\ldots$ $A_N$

Output

Print the sum of $\prod _{i = 1} ^N \dbinom{B_i}{A_i}$, modulo $(10^9 + 7)$.


Sample Input 1

3 5
1 2 1

Sample Output 1

8

There are four sequences $B$ such that $\prod _{i = 1} ^N \dbinom{B_i}{A_i}$ is at least $1$:

  • $B = \{1, 2, 1\}$, where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{1}{1} \times \dbinom{2}{2} \times \dbinom{1}{1} = 1$;

  • $B = \{2, 2, 1\}$, where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{2}{1} \times \dbinom{2}{2} \times \dbinom{1}{1} = 2$;

  • $B = \{1, 3, 1\}$, where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{1}{1} \times \dbinom{3}{2} \times \dbinom{1}{1} = 3$;

  • $B = \{1, 2, 2\}$, where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{1}{1} \times \dbinom{2}{2} \times \dbinom{2}{1} = 2$.

The sum of these is $1 + 2 + 3 + 2 = 8$.


Sample Input 2

10 998244353
31 41 59 26 53 58 97 93 23 84

Sample Output 2

642612171

Input

题意翻译

### 题目描述 我们有一个包含 $N$ 个非负整数的序列 $A$。 对于所有长度为 $N$ 且和不超过 $M$ 的非负整数序列 $B$,求 $\prod_{i = 1}^N {B_i \choose A_i}$ 之和, 对 $(10^9 + 7)$ 取模。 ### 数据范围 - $1 \le N \le 2000$ - $1 \le M \le 10^9$ - $0 \le A_i \le 2000$ ### 输入格式 第一行输入两个整 $N, M$,第二行 $N$ 个整数,表示序列 $A$。 ### 输出格式 一行,表示答案对 $(10^9 + 7)$ 取模的值。 ### 样例解释1 有四个序列 $B$ 满足 $\prod_{i=1}^N {B_i \choose A_i}$ 至少为 $1$: - $B = \{1, 2, 1\}, \prod_{i = 1}^N{B_i \choose A_i} = {1 \choose 1} \times {2 \choose 2} \times {1 \choose 1} = 1$; - $B = \{2, 2, 1\}, \prod_{i = 1}^N{B_i \choose A_i} = {2 \choose 1} \times {2 \choose 2} \times {1 \choose 1} = 2$; - $B = \{1, 3, 1\}, \prod_{i = 1}^N{B_i \choose A_i} = {1 \choose 1} \times {3 \choose 2} \times {1 \choose 1} = 3$; - $B = \{1, 2, 2\}, \prod_{i = 1}^N{B_i \choose A_i} = {1 \choose 1} \times {2 \choose 2} \times {2 \choose 1} = 2$. 它们的答案之和为 $1+2+3+2=8$。 ###### $\text{\tiny{Translated by @nr0728.}}$

加入题单

算法标签: