Algorithm title: UVA 10105 polynomial coefficients (number theory)

Source: Internet
Author: User

Polynomial coefficients

The Problem

The problem is to calculate the coefficients in expansion of polynomial (X1+X2+...+XK) n.

The Input

The input would consist of a set of pairs of lines. The the pair consists of two integers n andk separated with spaces (0<k,n<13). This is 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.

The Output

For each input pair of lines the output line should consist one integer, the coefficient by the monomialx1n1x2n2...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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.