AC Diary--the derivative function of the computational polynomial Openjudge 1.5 38

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.