eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Plotting Polynomials

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 \textbf{p(x) = a_nx^n + ... + a_1x + a_0} of degree \textbf{n}, we wish to plot this polynomial at the \textbf{m} integer points \textbf{x = 0, 1, ..., m−1}. A straightforward evaluation at these points requires \textbf{mn} multiplications and \textbf{mn} additions. One way to speed up the computation is to make use of results computed previously. For example, if \textbf{p(x) = a_1x + a_0} and \textbf{p(i)} has already been computed, then \textbf{p(i + 1) = p(i) + a_1}. Thus, each successive value of \textbf{p(x) }can be computed with one addition each. In general, we can compute \textbf{p(i + 1)} from \textbf{p(i)} with \textbf{n} additions, after the appropriate initialization has been done. If we initialize the constants \textbf{C_0}, \textbf{C_1}, ..., \textbf{C_n} appropriately, one can compute \textbf{p(i)} using the following pseudocode: \textbf{p(0) = C_0; t_1 = C_1; ... t_n = C_n;} \textbf{for i from 1 to m-1 do} \textbf{p(i) = p(i-1) + t_1;} \textbf{t_1 = t_1 + t_2;} \textbf{t_2 = t_2 + t_3;} \textbf{...} \textbf{...} \textbf{t_(n-1) = t_(n-1) + t_n;} \textbf{end} For example, if \textbf{p(x) = a_1x + a_0}, we can initialize \textbf{C_0 = a_0} and \textbf{C_1 = a_1}. Your task is to compute the constants \textbf{C_0}, \textbf{C_1}, ..., \textbf{C_n} for the above pseudocode to give the correct values for \textbf{p(i)} at \textbf{i = 0, ..., m − 1}. \InputFile The input consists of one case specified on a single line. The first integer is \textbf{n}, where \textbf{1} ≤ \textbf{n} ≤ \textbf{6}. This is followed by \textbf{n+1} integer coefficients \textbf{a_n}, ..., \textbf{a_1}, \textbf{a_0}. You may assume that \textbf{|a_i|} ≤ \textbf{50} for all \textbf{i}, and \textbf{a_n} ≠ \textbf{0}. \OutputFile Print the integers \textbf{C_0}, \textbf{C_1}, ..., \textbf{C_n}, separated by spaces.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1 5 2
Вихідні дані #1
2 5
Джерело 2013 ACM-ICPC North American Qualification Contest