Problem E
Plotting Polynomials
Graphical calculators have become popular among high school students. They allow functions to be plotted on screen with minimal efforts by the students. These calculators generally do not possess very fast processors. In this problem, you are asked to implement a method to speed up the plotting of a polynomial.
Given a polynomial
One way to speed up the computation is to make use of
results computed previously. For example, if
In general, we can compute
p(0) = C_0; t_1 = C_1; ... t_n = C_n; for i from 1 to m-1 do p(i) = p(i-1) + t_1; t_1 = t_1 + t_2; t_2 = t_2 + t_3; : : t_(n-1) = t_(n-1) + t_n; end
For example, if
Your task is to compute the constants
Input
The input consists of one case specified on a single line.
The first integer is
Output
Print the integers
Sample Input 1 | Sample Output 1 |
---|---|
1 5 2 |
2 5 |
Sample Input 2 | Sample Output 2 |
---|---|
2 2 -4 5 |
5 -2 4 |
Sample Input 3 | Sample Output 3 |
---|---|
6 1 -20 4 30 0 -1 2 |
2 14 -302 -2136 -3144 -600 720 |