11371 - Polynomial multiplication using linked list   

Description

You are required to use linked list to do the multiplication of two polynomials.

Input

The input contains two lines. Each lines presents a polynomial. The format of each line is looked like : "5 4 -3 2 1 0" which means polynomial "5x4-3x2+1x0".

Each polynomial must contain a constant term. (You can use this rule to determine whether the polynomial is end.)

For example, "-2 3 1 1 0 0" should be -2x3+1x1.

(The input polynomial should be arrangement in descending power.)

Output

Output the answer. Print a space character in the begining.

For example, if the input is

5 4 -3 2 1 0 (means 5x4-3x2+1)

-2 3 1 1 0 0 (means -2x3+1x1)

the output should be 

" -10 7 11 5 -5 3 1 1" (which means -10x7+11x5-5x3+x).

If the value of coefficient is 0, you don't have to print it.

(The output polynomial should be arrangement in descending power.)

Sample Input  Download

Sample Output  Download

Partial Judge Code

11371.c

Partial Judge Header

11371.h

Tags




Discuss