11284: [yosupo] Convolution - Multidimensional Convolution (Circular)
[Creator : ]
Description
A prime $p$, and polynomials in $K$ variables over $\mathbb{Z}/p\mathbb{Z}$, $f(x_1, x_2, ..., x_K)$ and $g(x_1, x_2, ..., x_K)$ are given.
Calculate a product of $f$ and $g$ with $\bmod (1-x_1^{N_1}, 1-x_2^{N_2}, ..., 1-x_K^{N_K})$.
Here, $N_i$ is a divisor of $p-1$.
Calculate a product of $f$ and $g$ with $\bmod (1-x_1^{N_1}, 1-x_2^{N_2}, ..., 1-x_K^{N_K})$.
Here, $N_i$ is a divisor of $p-1$.
Input
$P$ $K$
$N_1$ $N_2$ ... $N_K$
$f$
$g$
$f$, $g$ is the integer array of length $\prod N_i$ consisting of integers between $0$ and $p-1$.
$i = i_1 + i_2 N_1 + ... + i_K N_1 N_2 ... N_{K-1}$-th element is corresponded to the coefficient of the $(x_1^{i_1}, x_2^{i_2}, ..., x_K^{i_K})$.
$N_1$ $N_2$ ... $N_K$
$f$
$g$
$f$, $g$ is the integer array of length $\prod N_i$ consisting of integers between $0$ and $p-1$.
$i = i_1 + i_2 N_1 + ... + i_K N_1 N_2 ... N_{K-1}$-th element is corresponded to the coefficient of the $(x_1^{i_1}, x_2^{i_2}, ..., x_K^{i_K})$.
Output
$fg$
$fg$ is the integer array of length $\prod N_i$ consisting of integers between $0$ and $p-1$.
As the same with input format, $i = i_1 + i_2 N_1 + ... + i_K N_1 N_2 ... N_{K-1}$-th element is corresponded to the coefficient of the $(x_1^{i_1}, x_2^{i_2}, ..., x_K^{i_K})$.
$fg$ is the integer array of length $\prod N_i$ consisting of integers between $0$ and $p-1$.
As the same with input format, $i = i_1 + i_2 N_1 + ... + i_K N_1 N_2 ... N_{K-1}$-th element is corresponded to the coefficient of the $(x_1^{i_1}, x_2^{i_2}, ..., x_K^{i_K})$.
Constraints
- $2 \leq p \leq 10^9$
- $p$ is a prime
- $0 \leq K \leq 18$
- $\prod N_i \leq 2^{18}$
- $2 \leq N_i$
- $N_i$ is a divisor of $p-1$
- $p$ is a prime
- $0 \leq K \leq 18$
- $\prod N_i \leq 2^{18}$
- $2 \leq N_i$
- $N_i$ is a divisor of $p-1$
Sample 1 Input
101 1
5
1 2 3 4 5
6 7 8 9 10
Sample 1 Output
19 24 24 19 9
Sample 2 Input
13 2
2 3
1 2 3 4 5 6
7 8 9 10 11 12
Sample 2 Output
1 11 1 11 3 0
Sample 3 Input
998244353 0
123
456
Sample 3 Output
56088