10351 - problem1   

Description

You will be given N functions and their corresponding equations and asked to compute their product. For example, given N = 3, f1(x) = (x+2), f2(x) = (2x+1) and f3(x) = (x+3), then their product f1(x)*f2(x)*f3(x) = (2x3+11x2+17x+6).

Note:

(1)   All the coefficients are integers.

(2)   The powers of N functions are positive integers and smaller than 100.

(3)   0

 

The following is an excerpt of incomplete code:

 

#include

 

int main(){

 

    int m,power[10];

    int f[10][100]={0},g[100]={0};

    int i,j;

 

    scanf("%d",&m);

    for(i=0;i

        scanf("%d",&power[i]);

        for(j=0;j<=power[i];j++){

            scanf("%d",&f[i][j]);

        }

    }

 

   /*your code*/

 

    for(i=0;i<=???;i++){

        printf("%5d",g[i]);

    }

    printf(" ");

 

    return 0;

}

Input

There are several lines.

The first line represents N.

The next two lines represent the greatest power of the first equation and the coefficient of the first function.

The next two lines represent the greatest power of the second equation and the coefficient of the second function.

...

The next two lines represent the greatest power of the N-th equation and the coefficient of the N-th function.

Note that the coefficients are descending order and each element is separated by a blank.

Output

The coefficient of the product f1(x)*f2(x)*…*fN(x) with descending order.

Note that you need to use “%5d” to print answer and there is a new line at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss