
A = [1,2,3]
B = [3,2,1]
ANSWER:- The answer should be [3,8,14,8,3] as the polynomials are x^2 + 2x + 3 and 3x^2 + 2x + 1.On multiplying we get 3x^4 + 8x^3 + 14x^2 + 8x + 3 and hence the answer is [3, 8, 14, 8, 3].
The first line contains a single integer āTā representing the number of test cases. Then each test case follows.
The first line of every test case contains an integer āNā denoting the maximum degree of polynomial A and polynomial B.
The next line of every test case contains an array āAā denoting the coefficients of the first polynomial.
The next line of every test case contains an array āBā denoting the coefficients of the second polynomial.
For each test case, return an array denoting the coefficients of the resulting polynomial.
The output of each test case should be printed in a separate line.
You are not required to print anything, it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 10^4
1 <= A[i] <= 500
1 <= B[i] <= 500
Time Limit = 1 sec
Multiply every coefficient in B with every coefficient in A and add to the final result. Return the final result.
Use Fast-Fourier Transformation to multiply the polynomials faster. So let there be a polynomial A(x) with degree nā1, where n is a power of 2, and n>1.
We divide it into two smaller polynomials, the one containing only the coefficients of the even positions, and the one containing the coefficients of the odd positions:
Read more about FFT Transformation here:- https://cp-algorithms.com/algebra/fft.html