pat-B-10,101-yuan polynomial derivation

Source: Internet
Author: User

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

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.