38: Calculating the derivative function of a polynomial
-
Total time limit:
-
1000ms
-
Memory Limit:
-
65536kB
-
Describe
-
It is a very easy task to calculate the derivative of a polynomial. Given a function f (x), we use F ' (x) to denote its derivative function. We use X^n to represent the n power of X. In order to calculate the derivative of a polynomial, you must know three rules:
(1), (c) ' = 0 if C is constant
(2), (c*x^n) ' = c*n*x^ (n-1) if n >= 1 and C is constant
(3), (F1 (x) +f2 (2)) ' = F1 ' (x) +f2 ' (x)
It is easy to prove that the derivative function of polynomial is also polynomial.
Now, ask you to write a program that has a polynomial f (x) that does not contain a negative coefficient and has been merged to the same power, and calculates its derivative function.
-
Input
-
The input has two lines.
The first line is an integer n (0 <= n <= 100) indicating that the highest power of the polynomial is n.
The second line contains n+1 non-negative integers, cn, Cn-1, Cn-2, Cn-3, Cn-4, ..., c1,c0 (0 <= Ci <= 1000) and Cn! = 0. CI is the coefficient of the term of the power of I.
-
Output
-
Outputs the result of F ' (x) within a line.
(1) if g (x) = 0 Then direct output 0
(2) if G (X) shape such as cm (x^m) +cm-1 (x^ (m-1)) +...+c0 (cm!=0) then output Cm ... C0
(3) There is a single space between adjacent integers.
-
Sample input
-
301023 2 1310 0 1 2
-
Sample output
-
06 230 0 1
Ideas:
Just the topic is more difficult to read, the code is really mentioning Mo short;
Come on, on the code:
#include <cstdio>using namespacestd;intN;intMain () {scanf ("%d",&N); if(n==0) {printf ("0\n"); return 0; } intcur; for(intI=n;i>0; i--) {scanf ("%d",&cur); printf ("%d", cur*i); } return 0;}
AC Diary--the derivative function of the computational polynomial Openjudge 1.5 38