2431. Polynomial coefficients

单点时限: 2.0 sec

内存限制: 256 MB

The problem is to calculate the coefficients in expansion of polynomial (x1+x2+…+xk)n.

输入格式

The input will consist of N(0<N<3000) pairs of lines. The first line of the pair consists of two integers n and k separated with space (0 < k,n < 13). This integers define the power of the polynomial and the amount of the variables. The second line in each pair consists of k non-negative integers n1, …, nk, where n1+…+nk=n.

You can assume that all inputs are valid and can calculate the multiplication.

输出格式

For each input pair of lines the output line should consist one integer, the coefficient by the monomial x1n1x2n2…xknk in expansion of the polynomial (x1+x2+…+xk)n.

样例

Input
2
2 2
1 1
2 12
1 0 0 0 0 0 0 0 0 0 1 0
Output
2
2

8 人解决,23 人已尝试。

8 份提交通过,共有 37 份提交。

7.7 EMB 奖励。

创建: 16 年前.

修改: 7 年,4 月前.

最后提交: 1 年,5 月前.

来源: ECNU 选拔 2008

题目标签