
nthDerivative
Write a function which computes the nth
derivative of a polynomial evaluated at a point, modulo 109 + 7
. The output should be in the range [0, 109 + 7)
.
Example:
- For
coefficients = [3, 2, 1, 1]
,n = 2
andx = 100
, the output should benthDerivative(coefficients, n, x) = 602
.
The polynomial represented here isf(x) = 3 + 2x + x2 + x3
, which has a second derivative off''(x) = 2 + 6x
. Therefore, the answer isf''(100) = 602
.
Input/Output
-
[execution time limit] 0.5 seconds
-
[input] array.integer coefficients
The coefficients of the polynomial, where
coefficients[i]
is the coefficient ofxi
.Guaranteed constraints:
0 ≤ coefficients.length ≤ 5000
. -
[input] integer n
The number of derivatives to take before evaluating.
Guaranteed constraints:
0 ≤ n ≤ 1000
. -
[input] integer x
The value at which to evaluate the
nth
derivative.Guaranteed constraints:
-1000 ≤ x ≤ 1000
. -
[output] integer
- The
nth
derivative of the polynomial defined bycoefficients
evaluated atx
reduced modulo109 + 7
. The output should be in the range[0, 109 + 7)
.
- The
Post Comment