Multiplication and addition operation of unary polynomial

Source: Internet
Author: User

Description:

The product and sum of the two unary polynomials are obtained by the design function respectively.

Input Specification:

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 Specification:

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. The 0 polynomial should output 0 0.

Sample Input:

4 3 4-5 2 6 1-2 0
3 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 1
5 20-4 4-5 2 9 1-2 0

Multiplication and addition operation of unary polynomial

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.