The design function is to find the derivative of the polynomial of one element. (Note: The first-order derivative of xn (n is an integer) is n*xn-1. )
input format: input polynomial non-0 coefficients and exponents in exponential degradation (absolute values are integers not exceeding 1000). The numbers are separated by a space.
output format: outputs the coefficients and exponents of the derivative polynomial not 0 in the same format as the input. The numbers are separated by a space, but cannot have extra spaces at the end. Note that the exponent and coefficients for the "0 polynomial" are 0, but are expressed as "0 0".
Input Sample:
3 4-5 2 6 1-2 0
Sample output:
12 3-10 1) 6 0
1#include <stdio.h>2#include <stdlib.h>3#include <iostream>4#include <string.h>5#include <string>6#include <math.h>7#include <algorithm>8 using namespacestd;9 Ten One intMain () { A inta[1011]={0}; - intK,e,count=0; - while(SCANF ("%d%d", &k,&e)! =EOF) the { -a[e]=K; - } - //a[0]=0; + for(intI=1; i<=1010; i++) - { +a[i-1]=a[i]*i; A //a[i]=0; at if(a[i-1]!=0) count++; - } - if(count==0) printf ("0 0"); - Else - { - for(intI= +; i>=0; i--) in { - if(a[i]!=0) to { +printf"%d%d", a[i],i); -count--; the if(count!=0) printf (" "); * } $ }Panax Notoginseng } - the return 0; +}
1010. Derivation of a unary polynomial (25)