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

Angry Teacher

Angry Teacher

Mr. O'Cruel is teaching Math to ninth grade students. Students of course are very lazy, so they do not like to do their homework. On the other side, Mr. O'Cruel doesn't like lazy students. Recently Andrew failed to do his homework again, so he was given a special task. If he doesn't do it, he will be expelled from his school. The task seems very easy, but it is very technical, so it would take a lot of time. Andrew is given a polynomial \textbf{p(x) = a_nx^n + a_\{n-1\}x^\{n-1\} + ... + a_1x + a_0} with integer coefficients. He must calculate the value of the polynomial for \textbf{k} successive integer numbers starting from \textbf{l}. Of course writing all these numbers would require too much paper. So as a proof of completing the task, for each number xfrom \textbf{l} to \textbf{l+k-1}Andrew is asked to provide the sum of squares of \textbf{m} last digits in decimal notation of \textbf{p(x)}. Since Andrew is lazy, he doesn't want to do the task by himself. So he asks you to write the program that calculates the values requested. \InputFile The first line of the input contains \textbf{n}, \textbf{l}, \textbf{k}, and \textbf{m} (\textbf{0} ≤ \textbf{n} ≤ \textbf{10}, \textbf{0} ≤ \textbf{l} ≤ \textbf{10^1000}, \textbf{1} ≤ \textbf{k} ≤ \textbf{1000}, \textbf{1} ≤ \textbf{m} ≤ \textbf{1000}). The following \textbf{n+1} lines contain coefficients of the polynomial: \textbf{a_n}, \textbf{a_\{n-1\}}, ..., \textbf{a_1}, \textbf{a_0} (\textbf{0} ≤ \textbf{a_i} ≤ \textbf{10^1000}). \OutputFile Output \textbf{k} lines --- for \textbf{x} from \textbf{l} to \textbf{l+k-1} output the sum of squares of last \textbf{m} digits of \textbf{p(x)}.
Лимит времени 10 секунд
Лимит использования памяти 64 MiB
Входные данные #1
3 0 10 2
1
0
2
1
Выходные данные #1
1
16
10
25
58
45
85
89
85
80
Источник Northeastern Europe 2004, Northern Subregion