#P4893. GodFly's Big Integer Polynomial Derivative Challenge
GodFly's Big Integer Polynomial Derivative Challenge
GodFly's Big Integer Polynomial Derivative Challenge
In this problem, you are given an (n)th-degree polynomial with very large integer coefficients and an integer (k). Your task is to compute the (k)-th derivative of the polynomial.
Recall the following derivative rules:
(f(x)=ax^n) implies (f'(x)=a\cdot n \cdot x^{n-1}), and for a sum (F(x)=f(x)+g(x)), we have (F'(x)=f'(x)+g'(x)).
The operation of taking the (k)-th derivative means applying the differentiation process (k) times in succession. If (k) exceeds the degree of the polynomial, the resulting polynomial is defined to be 0.
For example, if (g(x)=ax^3+bx^2+c), then evaluating (g(x_0)) yields (ax_0^3+bx_0^2+c>.
inputFormat
The input consists of two lines:
- The first line contains two integers (n) and (k), where (n) is the degree of the polynomial and (k) is the order of the derivative to compute.
- The second line contains (n+1) space-separated integers representing the coefficients of the polynomial in descending order (from the coefficient of (x^n) down to the constant term).
outputFormat
Output the coefficients of the resulting polynomial after taking the (k)-th derivative, in descending order. If the resulting polynomial is 0, output a single zero (i.e. '0').
sample
3 1
3 0 -5 2
9 0 -5