11373 - Polynomial addition using linked list   

Description

You are required to use linked list to do the addition 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 1 1 0 (means 5x4-3x2-1x1+1)

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

the output should be 

" 5 4 -2 3 -3 2 1 0" (which means 5x4-2x3-3x2+1).

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

11373.c

Partial Judge Header

11373.h

Tags




Discuss