Problem9030--[yosupo] Convolution - Gcd Convolution

9030: [yosupo] Convolution - Gcd Convolution

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

Given integer sequences $a_1, ..., a_{N}$ and $b_1, ..., b_{N}$. 
Calculate an integer sequence $c_1, ..., c_{N}$ as follows:
$c_k = \sum_{\gcd(i,j)=k} a_ib_j \bmod 998244353$

Input

$N$
$a_1$ ... $a_{N}$
$b_1$ ... $b_{N}$

Output

$c_1$ ... $c_{N}$

Constraints

$1 \leq N \leq 10^6$
$0 \leq a_i, b_i < 998244353$

Sample 1 Input

6
1 2 3 4 5 6
6 5 4 3 2 1

Sample 1 Output

284 90 39 12 10 6

HINT

相同题目:yosupo

Source/Category