-->
当前位置:首页 > 题库

PROGRAMMING:Polynomial a divided by B

Luz5年前 (2021-05-10)题库387
This is still a problem about a / B, but a and B are both changed into polynomials. You need to calculate the quotient Q and the remainder r of the division of two polynomials, where the order of R must be less than the order of B.
###Input format:
Input is divided into two lines, each line gives a non-zero polynomial, first gives a, then B. The format of each line is as follows:
```
N e[1] c[1] ... e[N] c[N]
```
Where 'n' is the number of nonzero terms of the polynomial, 'E [i]' is the exponent of the 'I' nonzero term, and 'C [i]' is the coefficient of the 'I' nonzero term. Each item is given in the order of exponential decreasing, which ensures that all indexes are different non negative integers, all coefficients are non-zero integers, and all integers are in the range of integer.
###Output format:
The output format is the same as the input format, and the output coefficient retains one decimal place. The numbers in the same row shall be separated by one space, and there shall be no extra space at the beginning and end of the row. Note: the zero polynomial is a special polynomial, and the corresponding output is' 0.0 '. But non-zero polynomials can't output the term of zero coefficient (including 0.0 after rounding). In the example, the co polynomial actually has a constant term of '- 1 / 27', but it is not output because it is rounded to 0.0.
###Input example:
```in
4 4 1 2 -3 1 -1 0 -1
3 2 3 1 -2 0 1
```
###Output example:
```out
3 2 0.3 1 0.2 0 -1.0
1 1 -3.1
```






answer:If there is no answer, please comment