zoukankan      html  css  js  c++  java
  • zoj 2969 Easy Task

    ZOJ Problem Set - 2969
    Easy Task

    Time Limit: 1 Second      Memory Limit: 32768 KB

    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 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 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 integer T (1 <= T <= 1000) which is the number of test cases. And it will be followed by T 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 integer N (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 degree i 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 2
    30 0 1
    

    Author: CAO, Peng


    Source: The 5th Zhejiang Provincial Collegiate Programming Contest
    Submit    Status
    //Wpl
    //1786815 2009-03-12 20:30:35 Accepted  2969 C++ 20 184 吴
    //ZOJ 2969 Easy Task 简单积分题 08年浙江省大学生程序设计竞赛
    #include <iostream>
    using namespace std;
    int C[105];
    int main()
    {
        
    int t;
        scanf(
    "%d",&t);
        
    while(t--)
        {
            
    int n,i;
            scanf(
    "%d",&n);
            
    for(i=0;i<=n;i++)
                scanf(
    "%d",&C[i]);
            
    for(i=0;i<=n;i++)
                C[i]
    =C[i]*(n-i);
            
    for(i=0;i<n-1;i++)
                printf(
    "%d ",C[i]);
            printf(
    "%d\n",C[i]);
        }
        
    return 0;
    }
  • 相关阅读:
    JQuery实现1024小游戏
    Windows Server2008 R2安装wampserver缺少api-ms-win-crt-runtime-l1-1-0.dll解决方案
    ASP.NET MVC 邮件发送的功能(微软邮箱发送)。
    浅谈撞库防御策略
    极验高并发验证服务背后的技术实现
    2015年国内数据安全事件盘点
    转载——验证码的昨天、今天和明天
    转载——最近百度云盘不提供搜索,闲来无事,玩玩python爬虫,爬一下百度云盘的资源
    SQL 查询语句
    SQL Server 目录
  • 原文地址:https://www.cnblogs.com/forever4444/p/1454655.html
Copyright © 2011-2022 走看看