COEF - Coeficientes

The problem is to calculate the coefficients in expansion of polynomial (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 < n, k <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.

Output

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.

Example

Input:
2 2
1 1
2 12
1 0 0 0 0 0 0 0 0 0 1 0

Output:
2
2

Added by:Coach UTN FRSF
Date:2010-06-02
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 SQLITE VB.NET
Resource:http://uva.onlinejudge.org/external/101/10105.html

hide comments
2013-03-27 08:23:05 Yashpal
getting WA....
edit(francky) : Please use the forum for that. Read the notes below.

Last edit: 2013-03-27 09:31:28
2012-11-18 17:05:06 Venkatesh Ganesan
what's the input termination condition? no limit given
@namandeep What u said is giving errors
2012-06-30 12:15:43 RANA
easy one.... :)
2012-05-26 19:41:40 sachin tendulkar
THANX NAMANDEEP
2012-05-02 14:00:06 (Tjandra Satria Gunawan)(曾毅昆)
easy... :)
2012-01-20 14:40:51 Aman Kumar
was getting WA in c++, submitted in C and got AC..
2011-11-21 16:35:12 saket diwakar
AC....easy one
2011-10-06 16:05:21 Naman
for c/c++ users
while(scanf("%d %d",&n,&k)!=EOF) for input
2011-02-03 07:46:39 HELLO
please help me
what will be the termination condition????
2010-11-15 19:05:18 [Retired]
AC....

Last edit: 2010-12-12 18:38:35
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.