Chef And The Polynomial
All submissions for this problem are available.
The Chef is fond of polynomials so he decides to fix the rate of the food items in the form of a polynomial equation for his hotel.
He decides to put the rate of the items in the form of coefficients of the polynomial where, if the rate of tea is "a1" and rate of sandwich is "a2” and so on, then the rate list will be in the form of a0 *x^0+ a1 *x^1.......aN-1 *x^(N-1).
But his competitor Ciel copies this policy .In the same way, Ciel also designs a polynomial rate list for his hotel. But this makes the condition miserable for both of them as the profit gets divided in an unbalanced form. So both of them decide to multiply the coefficient of their polynomial and get a resultant polynomial. They put the resultant list on their rate boards. But they are weak in mathematics so help them to do this task!!
First line of the Input contains T, the number of test cases.
Each test case is given as follows:
Two space separated integers , N1 and N2 which denote the degree of polynomials of Chef and Ciel respectively.
The second line contains N1+1 coefficients in the order of a0 a1 .......aN1. These coefficients denote the coefficients of Chef’s polynomial .
The second line contains N2+1 coefficients in the order of a0 a1 .......aN2. These coefficients denote the coefficients of Ciel’s polynomial .
First line of the output should have the degree of the resultant polynomial, N.
Second line of the output should have the resultant polynomial coefficients for their hotels in the order of a0 a1 ....... aN all separated by a space.Since the coefficients can be large print their value mod 2^32
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ T ≤ 10
- 0 ≤ N1,N2 ≤ 100000
- 1 ≤ value of the coefficients (a0, a1 ,..)<= ≤ 1000
Input: 2 1 1 1 2 2 3 2 0 1 2 3 4
Output: 2 2 7 6 2 4 8 12
NOTE : Use fast Input Output.
|Time Limit:||3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, GO, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.