P-Izvod
You are given two polynomials. Calculate the first derivative of their product.
InputThe first line of the standard input will contain two integers, N and M (0< N,M <= 1000) which represent the amount of monomials in each polynomial, respectively. The remainder of the input will contain two lines, within each one of them a sequence of characters representing the polynomial. The polynomial will contain one or more monomials, out of which each will be in the following format:
<op> <A>x^<exp> where:
op is an addition or subtraction operator ('+' or '-')
A is the integer coefficient (0 < A <= 100)
exp is the integer exponent (0 <= exp <= 100)
It is not guaranteed that all the monomials will have different degrees, or that they will be in any kind of order.
<op> <A>x^<exp> where:
op is an addition or subtraction operator ('+' or '-')
A is the integer coefficient (0 < A <= 100)
exp is the integer exponent (0 <= exp <= 100)
It is not guaranteed that all the monomials will have different degrees, or that they will be in any kind of order.
OutputWrite to the standard output the first derivative of the product of the given two functions. It should be outputted in the same format as the input, with restrictions that there may be no two monomials of the same degree, and that the monomials should be ordered from the largest to the smallest degree. Also, if the result contains a constant, output it without adding x^0, and if the result contains a first-degree monomial, output it without adding the exponent. If the first monomial in the solution has a positive coefficient, print it without adding the "+" in front. The solution must be outputted without spaces.
Input:
Output:
4 3
- 1x^8 + 5x^5 + 2x^1 + 1x^0
+ 2x^2 + 3x^1 - 2x^0Output:
-20x^9-27x^8+16x^7+70x^6+90x^5-50x^4+12x^2+16x-1 Input:
Output:
2 1
+ 4x^0 + 100x^0
+ 99x^0Output:
0 Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.