ZOJ2969-Easy Task
来源:互联网 发布:手机怎么开淘宝网店 编辑:程序博客网 时间:2024/06/05 18:05
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
301023 2 1310 0 1 2
Sample Output
06 230 0 1
Author: CAO, Peng
Source: The 5th Zhejiang Provincial Collegiate Programming Contest
题意: 给出n,代表多项式有n+1项,要求多项式求导后每一项的系数,若不止有常数项,常数项就不用输出
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>using namespace std;#define LL long longint main(){ int a[200],n; int t; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=0; i<=n; i++) scanf("%d",&a[i]); for(int i=0; i<n; i++) { if(i!=0) printf(" "); printf("%d",a[i]*(n-i)); } if(n==0) printf("0"); printf("\n"); } return 0;}
- ZOJ2969-Easy Task
- ZOJ2969
- zoj2969
- ZOJ2969
- Easy Task
- Easy Task
- Easy Task
- 1076 An Easy Task
- ZOJ 2969 Easy Task
- An Easy Task
- An Easy Task
- BNU16488:Easy Task
- An Easy Task
- An Easy Task
- 1076 An Easy Task
- hdu An Easy Task
- hdu1076 An Easy Task
- FOJ1138 Easy Task
- KBEngine服务器demo中的AI(人工智能)
- 学好数据库,看这9本书就够了
- HDU1754 I Hate It 简单线段树
- android: binder: error log: binder_alloc_buf, no vma
- 将当前目录下cifar-10-batches-py转换成train图片和test图片,并同时生成train.txt 和 test.txt
- ZOJ2969-Easy Task
- POJ 3468 A Simple Problem with Integers 线段树(成段更新)
- 用keytool创建秘钥库以及导入导出数字证书等操作
- ADB 常用命令
- Swift实现弹出菜单
- Swift实现弹出菜单
- BUG实例分析五:binder alloc buf, no vma
- Android 使用Vector XML文件创建矢量图片资源
- 【LeetCode笔记】Convert Sorted Array to Binary Search Tree 通过有序数列建立二叉搜索树