u have already the task
Question Description
I’m working on a python question and need an explanation and answer to help me learn.
don’t have much time to fill it here Write a program for addition, multiplication and division with the remainder of sparse polynomials, i.e. polynomials for which we store only non-zero terms.
A sparse polynomial is specified as a sequence of pairs (e,x), where e is the exponent and x the corresponding coefficient. Pairs are listed in order of decreasing exponents, each on a separate line. The entire polynomial is terminated by the line -1 -1. We never list pairs with zero coefficients, especially the zero polynomial is represented by the line -1 -1 itself.
For example, we write the polynomial 3x?5?x?2+7 as follows:
5 3
2 -1
0 7
-1 -1
The first line of input tells us what operation to perform: add for addition, mul for multiplication, or div for division with a remainder. Two sparse polynomials are entered on the next lines.
Write the result of the operation again in the form of a sparse polynomial. The result of the div operation is two polynomials: the quotient and the remainder after division. Note that the division may result in odd numbers; list them as fractions (we recommend using the Fraction type for calculations).
For example: I need to work this for general input !!
for input
add
6 1
4 3
3 -3
0 5
-1 -1
3 3
0 -3
-1 -1
is the correct output
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."