#P9501. 「RiOI-2」likely

    ID: 9989 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学数论洛谷原创O2优化生成函数快速数论变换 NTT洛谷月赛

「RiOI-2」likely

Background

Little E likes to arrange things in a circle rather than in a chain.

Recently, she learned about plus and minus signs at school. She put them on the circle as a password.

However, she has now forgotten it and only sees a number on the draft paper. What is it?

Problem Description

For a sequence a0an1a_0 \dots a_{n-1} of length nn that contains only ±1\pm1, define $S(a, m) = \displaystyle \sum_{k = 0}^{n - 1} \prod_{l = 0}^{m - 1} a_{(k + l) \bmod n}$.

Given n,m,kn, m, k, among the 2n2^n different sequences aa, find how many different aa satisfy S(a,m)=kS(a, m) = k.

Output the answer modulo 998, ⁣244, ⁣353998,\!244,\!353.

Input Format

This problem contains multiple test cases.

The first line contains a positive integer TT, the number of test cases.

The next TT lines each contain three integers, in order: n,m,kn, m, k.

Output Format

Output TT lines. Each line contains one integer, the answer for one test case.

9
4 2 0
9 9 -9
9 3 3
20 8 -12
114 5 14
191 9 81
1036 854 104
998244 353 4
2147483 64 7
12
256
108
10000
661235724
741150826
500003636
222931421
404094315
6
8 4 0
12 4 0
16 4 0
20 4 0
24 4 0
28 4 0
176
1728
26160
368000
5413856
80212608
4
6 2 0
10 2 0
9 9 7
9 3 6
0
0
0
0

Hint

Sample Explanation

For the first test case’s first dataset, the only sequences that do not satisfy the condition are a=[1,1,1,1]a = [1, 1, 1, 1], a=[1,1,1,1]a = [-1, -1, -1, -1], a=[1,1,1,1]a = [1, -1, 1, -1], and a=[1,1,1,1]a = [-1, 1, -1, 1], so the answer is 244=122^4 - 4 = 12.

For the first test case’s second dataset, the only sequences that satisfy the condition are those where aa contains an odd number of 1-1, so the answer is 28=2562^8 = 256.

Constraints and Notes

This problem uses bundled testdata.

Subtask\text{Subtask} Score TT \leq n\sum n \leq mm \leq
00 55 11 2020 /
11 1010 55 10510^5 22
22 44
33 1515 / 7×1037\times10^3 /
44 2020 10510^5
55 4040 /

For all testdata, it is guaranteed that 2mn5×1062 \leq m \leq n \leq 5\times 10^6, 0kn0 \leq \lvert k\rvert \leq n, 1T101 \leq T \leq 10, and n5×106\sum n \leq 5\times10^6.

Translated by ChatGPT 5