ZJU oj 2969 Easy Task(水题)
来源:互联网 发布:pdg2pic mac 编辑:程序博客网 时间:2024/05/17 09:28
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 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 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 integersCm,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
给你一个多项式的系数,让你求这个多项式求导之后的系数,注意n == 0的话,直接输出0,并且常数求导之后不输出
#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main(){ int t; int n; int a[1005]; scanf("%d",&t); while(t--) { int flag; int cnt = 0; scanf("%d",&n); for(int i=1;i<=n+1;i++) scanf("%d",&a[i]); if(n == 0) { printf("0\n"); continue; } for(int i=1;i<=n;i++) { a[i] = a[i]*(n+1-i); } for(int i=1;i<=n;i++) { printf("%d",a[i]); if(i!=n) printf(" "); } printf("\n"); }}
- ZJU oj 2969 Easy Task(水题)
- 杭电OJ--1076 An Easy Task
- hdu-oj 1076 An Easy Task
- 杭电oj-1076-An Easy Task
- 杭电oj-An Easy Task
- ZOJ 2969 Easy Task(模拟)
- ZOJ 2969 Easy Task
- ZOJ 2969 Easy Task
- ZOJ 2969 Easy Task
- ZOJ 2969Easy Task
- hdu 1076 An Easy Task (水题)
- ZJU oj 2970 Faster, Higher, Stronger(水题)
- ZOJ 2969 && BNU16488 Easy Task
- zoj 3844 Easy Task(水题)
- ACM水题 An easy task
- An Easy Task(简箪题)
- Easy Task(数学求导)
- zoj 2965 Accurately Say "CocaCola"! 2969 Easy Task(水~~)
- 魔板拼图
- BaseAdapter 的优化
- [学习笔记]AJAX入门学习总结
- Web研发模式演变
- Struts2 入门学习笔记(五)——上传下载
- ZJU oj 2969 Easy Task(水题)
- EF异常:“System.InvalidOperationException”类型的未经处理的异常在 mscorlib.dll 中发生
- nyoj 20 吝啬的国度<vector容器>
- MySQL免安装版完整配置
- 同时修改多个文件后缀名
- 关于href="javascript:void 0;"
- 关于android.widget.View.jumpDrawablesToCurrentState问题
- 使用Android Studio 1.3 版本进行NDK开发
- Eclipse快捷键与功能使用