eolymp
bolt
Try our new interface for solving problems
Problems

Polynomial

Polynomial

Polynomial \textbf{P}(\textbf{x}) = \textbf{a_0} + \textbf{a_1x} + \textbf{a_2x^2} + ... + \textbf{a_\{n-1\}x^\{n-1\}} given set of coefficients \textbf{a_0}, \textbf{a_1}, ..., \textbf{a_\{n-1\}}. Required to calculate the value of this polynomial modulo \textbf{m} for all integer \textbf{x} from \textbf{0} to \textbf{a} given number \textbf{k}. \InputFile In the first line of the input file contains the numbers \textbf{n}, \textbf{k} and \textbf{m} (\textbf{1} ≤ \textbf{n} ≤ \textbf{2000}, \textbf{1} ≤ \textbf{k} ≤ \textbf{200000}, \textbf{1} ≤ \textbf{m} ≤ \textbf{10^9}). The second line contains the coefficients of \textbf{a_0}, \textbf{a_1}, ..., \textbf{a_\{n-1\}} --- non-negative integers not exceeding \textbf{10^9}. \OutputFile The output file output \textbf{k+1} number - the remnants of the division of the values of \textbf{P}(\textbf{0}), \textbf{P}(\textbf{1}), ..., \textbf{P}(\textbf{k}) on \textbf{m}.
Time limit 7 seconds
Memory limit 256 MiB
Input example #1
2 4 239
17 3
Output example #1
17 20 23 26 29
Author Dmitriy Zhukov
Source Winter School, Kharkov, 2011, Day 2