通过 K 整除交换得到的有效数组AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given an integer sequence $A$ of length $N$ and a positive integer $K$.
You can perform the following operation on $A$ any number of times:
给定一个长度为 $N$ 的整数序列 $A$ 和一个正整数 $K$。
你可以对 $A$ 执行以下操作任意次:AI (CI翻译)
- Choose an integer
$i$with$1 \leq i \leq N-1$such that$A_i + A_{i+1}$is divisible by$K$, and swap$A_i$and$A_{i+1}$.
- 选择一个满足
$1 \leq i \leq N-1$且$A_i + A_{i+1}$能被$K$整除的整数$i$,然后交换$A_i$和$A_{i+1}$。
Find the total number, modulo $998244353$, of distinct sequences that $A$ can become after performing the operation zero or more times.
求经过零次或多次操作后,$A$ 能变成的不同序列总数,答案对 $998244353$ 取模。AI (CI翻译)
Solve $T$ test cases per input.
每个输入包含 $T$ 组测试用例。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \leq T \leq 10^5$$2 \leq N \leq 2 \times 10^5$$1 \leq K \leq 10^9$$1 \leq A_i \leq 10^9$- The sum of
$N$over all test cases is at most$2 \times 10^5$. - All input values are integers.
$1 \leq T \leq 10^5$$2 \leq N \leq 2 \times 10^5$$1 \leq K \leq 10^9$$1 \leq A_i \leq 10^9$- 所有测试用例的
$N$之和不超过$2 \times 10^5$。 - 输入中的所有数值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入通过标准输入给出,格式如下:AI (CI翻译)
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_TAI (CI翻译)
Each test case $\mathrm{case}_t$ is given in the following format:
每组测试用例 $\mathrm{case}_t$ 的格式如下:AI (CI翻译)
N K
A_1 A_2 \dots A_N
N K
A_1 A_2 \dots A_NAI (CI翻译)
Output
输出格式
AI (CI翻译)Output the answers over a total of $T$ lines. The $t$-th line should contain the answer for the $t$-th test case.
共输出 $T$ 行答案。第 $t$ 行应包含第 $t$ 组测试用例的答案。AI (CI翻译)
样例
3
4 3
1 2 4 7
6 4
1 5 3 6 2 4
3 2
2 2 3
4
6
1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。