2014ACM集训13级PK赛5-Easy Task
2014-03-16 19:54
351 查看
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 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
Sample Output
06 230 0 1
求导的题目,还算轻松
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
06 230 0 1
求导的题目,还算轻松
#include <string.h> #include <stdio.h> #include <math.h> #include <stdlib.h> int main() { int N; scanf ("%d",&N); while (N--) { int n,i; scanf ("%d",&n); for (i = n;i >= 0;i--) { int tmp; scanf ("%d",&tmp); if (i > 0) printf ("%d",tmp * i); else if (n == 0) printf ("0"); if (i > 1) printf (" "); else if (i == 0) printf ("\n"); } } return 0; }
相关文章推荐
- 2014ACM集训13级PK赛2-Conic Section
- 2014ACM集训13级PK赛4-Second-price Auction
- 2014ACM集训13级PK赛2-Kagome Kagome
- 2014ACM集训13级PK赛4-80ers' Memory
- 2014ACM集训13级PK赛2-Javabeans
- 2014ACM集训13级PK赛4-A Stack or A Queue?
- 2014ACM集训13级PK赛2-Median
- 2014ACM集训13级PK赛4-K-Nice
- 2014ACM集训13级PK赛4-Light Bulb
- 2014ACM集训13级PK赛3-Draw Something Cheat
- 2014ACM集训13级PK赛3-Modular Inverse
- 2014ACM集训13级PK赛5- Accurately Say "CocaCola"!
- 2014ACM集训13级PK赛3-Yet Another Story of Rock-paper-scissors
- 2014ACM集训13级PK赛3-Break Standard Weight
- 2014ACM集训13级PK赛5-Faster, Higher, Stronger
- 2014ACM集训13级PK赛2-Who is Older?
- 2014ACM集训13级PK赛5-Give Me the Number
- 2014ACM集训13级PK赛2-Somali Pirates
- 2014ACM集训13级PK赛3-Friends
- 2014ACM集训13级PK赛2-An Awful Problem