시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
4 초 | 256 MB | 4 | 3 | 3 | 75.000% |
For sure you have seen puzzles like "Given the sequence, find its next element". They seem logical in your childhood, but later you begin to understand that you can write any number and justify it with some tricky construction.
In this problem you have to continue the sequence "in the easiest way". Still not strict enough? Let us give a formal definition.
Let the hardness of the sequence $a_{1}, a_{2}, \ldots, a_{n}$ be the minimum integer $d$ such that there exists a polynomial $p$ of degree $d$ for which $p(x) \equiv a_{x} \pmod{998\,244\,353}$ for all $x$ from $1$ to $n$. For this problem, consider the polynomial $p(x) = 0$ to have degree $-1$.
Given a sequence $a_{1}, a_{2}, ..., a_{n}$ of size $n$, your task is to construct a sequence $b_{1}, b_{2}, \ldots, b_{n+m}$ of size $n+m$ such that:
The first line of input contains two integers $n$ and $m$ ($1 \le n \le 10^{5}$, $1 \le m \le 8 \cdot 10^{5}$).
The second line of input contains $n$ integers $a_{i}$: the initial sequence ($0 \le a_{i} < 998\,244\,353$).
Print $m$ integers $b_{n+1}, b_{n+2}, \ldots, b_{n+m}$ separated by spaces.
5 10 1 4 9 16 25
36 49 64 81 100 121 144 169 196 225
3 3 0 0 0
0 0 0
5 10 1 2 4 8 16
31 57 99 163 256 386 562 794 1093 1471
3 1 2 1 0
998244352
The notation $u \equiv v \pmod{p}$ means that $u$ and $v$ have the same remainder modulo $p$.