The product and sum of the two unary polynomials are obtained by the design function respectively.
Input format:
Input is divided into 2 lines, each line is given the number of non-0 polynomial, and then the exponential degradation way to enter a polynomial non-0 coefficients and exponents (absolute value is not more than 1000 integers). The numbers are separated by a space.
Output format:
The output is divided into 2 rows, and the coefficients and exponents of the product polynomial and the polynomial non-0 are output in exponential degradation mode respectively. The numbers are separated by a space, but cannot have extra spaces at the end.
Input Sample:
4 3 4 -5 2 6 1 -2 03 5 20 -7 4 3 1
Sample output:
15 24 -25 22 30 21 -10 20 -21 8 35 6 -33 5 14 4 -15 3 18 2 -6 15 20 -4 4 -5 2 9 1 -2 0
题目分析:
China University mooc-Chen, He Chinming-data structure-2015 Autumn 02-LINEAR structure 1