No.931 Multiplicative Convolution
Problem Statement
You are given a prime $P$ and integer sequences $A_1,A_2,\dots,A_{P-1}$ and $B_1,B_2,\dots,B_{P-1}$.
Find the integer sequence $C_1,C_2,\dots,C_{P-1}$.
Here,
\[
C_k=\sum_{1 \le i,j \lt P\\ k=(i\times j) \mod P}A_iB_j
\]
and you should output these values modulo $998244353$.
(That is, $C_k$ is the sum of $A_iB_j$ over all pairs $(i,j)$ such that the remainder of $i\times j$ divided by $P$ is $k$.)
Constraints
・$2\le P\le 99991$・$0\le A_i,B_i \lt 998244353$
・All input values are integers
・$P$ is prime
Input
$P$
$A_1\ A_2\ \dots\ A_{P-1}$
$B_1\ B_2\ \dots\ B_{P-1}$
Output
Output $C_1,C_2,\dots,C_{P-1}$ modulo $998244353$, separated by spaces.
Print a newline at the end.
Sample
Sample 1
Input
3 1 2 3 4
Output
11 10
$C_1=A_1B_1+A_2B_2\mod 998244353=11$
$C_2=A_1B_2+A_2B_1\mod 998244353=10$
as shown above.
Sample 2
Input
11 2 3 5 8 1 3 2 1 3 4 5 5 8 9 1 4 4 2 3 3
Output
172 129 138 127 162 138 149 148 129 116
Sample 3
Input
2 8886 112339
Output
1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
risujiroh
pockyny