The design function is to find the derivative of the polynomial of one element. NoteX?N?? (n as integers" for the first derivative of n< Span class= "Mord" >x? n? 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:
The coefficients and exponents of the derivative polynomial not 0 are output 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 all 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
分析:
按照求导公式求即可
PS:
注意判断输入结束条件为:多项式的指数为0
注意输出格式:末尾没有多余字符
//C + +#include <iostream>using namespacestd;intMain () {intb; intx =1; while(cin>>a>>b) { if(b = =0) Break; if(!x) cout<<" "; Elsex=0; cout<< a*b <<" "<<b-1; } if(x) cout<<"0 0"; return 0;}
pat-B-10,101-yuan polynomial derivation