Easy Task

点击打开链接

 

 

Easy Task

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 11   Accepted Submission(s) : 7
Problem Description
            Calculating the derivation of a polynomial is an easy task. Given a function f(x) , we use (f(x))' to denote its derivation. We use x^n to denote x n. 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 is easy to prove that the derivation a polynomial is also a polynomial.

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

Input

Standard input will contain multiple test cases. The first line of the input is a single integerT (1 <=T <= 1000) which is the number of test cases. And it will be followed byT consecutive test cases. 

There are exactly 2 lines in each test case. The first line of each test case is 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 <= 1000), which are the coefficients of f(x). Ci is the coefficient of the term with degreei in f(x). (CN!=0)

Output

For each test case calculate the result polynomial g(x) also in a single line.
(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 integers Cm,Cm-1,...C0.
(3) There is a single space between two integers but no spaces after the last integer.

Sample Input

3
0
10
2
3 2 1
3
10 0 1 2

Sample Output

0
6 
 
 

比较简单。

 

#include<stdio.h>
int z[1007];
int main()
{
    int m;
    while(scanf("%d",&m)!=EOF)
    {
        while(m--)
        {
            int x,count,ans,y;
            scanf("%d",&x);
            if(x==0){scanf("%d",&y);printf("0\n");}
            else
            {
                for(int a=1; a<=x+1; a++)
                    scanf("%d",&z[a]);
                count=x;
                for(int b=1; b<x; b++)
                {
                    ans=z[b]*count;
                    count--;
                    printf("%d ",ans);
                }
                printf("%d",z[x]*count);
                printf("\n");
            }
        }


    }
    return 0;
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值