Welcome To SDIBT ACM-ICPC Online Judge

VIRTUAL JUDGE Recent Contest F.A.Qs Discuss Home ProblemSet Status Ranklist 4 Contest LoginRegister Exam
Problem 1051. -- Polynomial coefficients

Polynomial coefficients

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 4  Solved: 3
[Submit][Status][Discuss]

Description

This problem seeks the coefficients resulting from the expansion of the polynomial

P = (x1 + x2 + ... + xk)n

Input

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

Output

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

Sample Input

2 2
1 1
2 12
1 0 0 0 0 0 0 0 0 0 1 0

Sample Output

2
2

HINT

Source

[Submit][Status][Discuss]

HOME Back

한국어 中文 English
All Copyright Reserved 2008-2010 SDIBT TEAM
GPL2.0 2003-2010 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin