TopCoder

User's AC Ratio

100.0% (1/1)

Submission's AC Ratio

100.0% (1/1)

Tags

Description

Given a prime $P$ and integer sequences $a_ 0, a_ 1, ..., a_ {P - 1}$ and $b_ 0, b_ 1, ..., b_ {P - 1}$. Calculate an integer sequence $c_ 0, c_ 1, ..., c_ {P - 1}$ as follows:

$$c_ k = \sum_ {i \times j \equiv k \pmod{P}} a_ i b_ j \bmod 998244353$$

Input Format

$P$
$a_ 0$ $a_ 1$ ... $a_ {P - 1}$
$b_ 0$ $b_ 1$ ... $b_ {P - 1}$

Output Format

$c_ 0$ $c_ 1$ ... $c_ {P - 1}$

Sample Input 1

5
9 7 5 3 1
8 6 4 2 0

Sample Output 1

308 64 60 36 32

Sample Input 2

2
0 998244352
0 998244352

Sample Output 2

0 1

Hints

  • $2 \leq P \leq 2^ {19}$
  • $P$ is a prime
  • $0 \leq a_ i, b_ i < 998244353$

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152
12 5000 2097152 2097152
13 5000 2097152 2097152
14 5000 2097152 2097152
15 5000 2097152 2097152
16 5000 2097152 2097152
17 5000 2097152 2097152
18 5000 2097152 2097152
19 5000 2097152 2097152
20 5000 2097152 2097152
21 5000 2097152 2097152
22 5000 2097152 2097152
23 5000 2097152 2097152
24 5000 2097152 2097152
25 5000 2097152 2097152
26 5000 2097152 2097152
27 5000 2097152 2097152
28 5000 2097152 2097152
29 5000 2097152 2097152
30 5000 2097152 2097152
31 5000 2097152 2097152
32 5000 2097152 2097152
33 5000 2097152 2097152
34 5000 2097152 2097152
35 5000 2097152 2097152
36 5000 2097152 2097152
37 5000 2097152 2097152
38 5000 2097152 2097152
39 5000 2097152 2097152