Harbin Tech 2015 summer Training BNU16488 Easy Task (simple question)

Source: Internet
Author: User

A-Easy TaskTime limit:$ MS Memory Limit:65536KB 64bit IO Format:%lld &am P %llu SubmitStatusPracticeZOJ 2969

Description

Calculating the derivation of a polynomial is an easy task. Given a function f (x), we use the (f (x)) ' to denote its derivation. We use the x^n to denote xn. To calculate the derivation of a polynomial, you should know 3 rules:
(1) (c) ' =0 where C is a constant.
(2) (cx^n) ' =c*n*x^ (n-1) where n>=1 and C is a constant.
(3) (F1 (x) +f2 (x)) ' = (F1 (x)) ' + (F2 (x)) '.
It's easy to prove the derivation a polynomial is also a polynomial.

Here comes the problem, given a polynomial f (x) with non-negative coefficients, can-write a program to calculate the D Erivation of it?

Input

Standard input would contain multiple test cases. The first line of the input was a single integert (1 <= T <=) which was the number of the test case S. And it'll be followed byT consecutive test cases.

There is exactly 2 lines in each test case. The first line of all test case was a single line containing an integerN (0 <= n <= 100). The second line contains N + 1 non-negative integers,CN, CN-1, ..., C1, C0, ( 0 <= Ci <=), which is the coefficients of f (x). Ci is the coefficient of the term with degree I in f (x). (CN!=0)

Output

For each test case calculate the result polynomial g (x) Also
(1) If g (x) = 0 just output integer 0.otherwise
(2) Suppose g (x) = Cmx^m+Cm-1x^ (m-1) +...+C0 (Cm! = 0), then output the integersCm,Cm-1,... C0.
(3) There is a single space between the integers and no spaces after the last integer.

Sample Input

301023 2 1310 0 1 2

Sample Output

06 230 0 1 Field second kill problem. Not explained.
#include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include < string.h> #include <cctype> #include <string> #include <cmath> #include <vector> #include <stack> #include <queue> #include <map> #include <set>using namespace Std;int main () {    int CNT[10000];    int t;cin>>t;    while (t--)    {        int n;cin>>n;        for (int i=0;i<=n;i++)        {            scanf ("%d", &cnt[i]);        }        if (n==0)        {            cout<<0<<endl;continue;        }        int x=n;        cout<<cnt[0]*x;x--;        for (int i=1;i<n;i++)        {            cout<< "" <<cnt[i]*x;            x--;        }        cout<<endl;    }    return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Harbin Tech 2015 summer Training BNU16488 Easy Task (simple question)

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.