A graphing calculator draws a function on screen with almost no work from the student. The processor in such a calculator is slow, so the drawing routine has to be economical. This problem asks you to implement a method that speeds up the plotting of a polynomial.
Given a polynomial p(x)=anxn+⋯+a1x+a0 of degree n, you want to plot it at the m integer points x=0,1,…,m−1. Evaluating the polynomial directly at each point costs mn multiplications and mn additions.
Reusing earlier results cuts that cost. If p(x)=a1x+a0 and p(i) is already known, then p(i+1)=p(i)+a1, so every later value costs one addition.
In general, once the initialization is done, n additions turn p(i) into p(i+1). With the constants C0,C1,…,Cn chosen correctly, the pseudocode below produces p(i).
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 p(x)=a1x+a0 you can take C0=a0 and C1=a1.
Compute the constants C0,C1,…,Cn that make the pseudocode give the correct value of p(i) for every i=0,…,m−1.
The input is a single line. The first integer is n, with 1≤n≤6. It is followed by the n+1 integer coefficients an,…,a1,a0. Every coefficient satisfies ∣ai∣≤50, and an=0.
Print C0,C1,…,Cn on one line, separated by single spaces.