等差数列乘积的最大公约数AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given positive integers $N, B, C, D$.
给定正整数 $N, B, C, D$。AI (CI翻译)
For a non-negative integer $k$, define the integer $a_k$ as the product of all terms of an arithmetic sequence with first term $Bk + C$, common difference $D$, and $N$ terms; that is, $a_k = (Bk+C)(Bk+C+D)(Bk+C+2D)\dots(Bk+C+(N-1)D)$.
对于非负整数 $k$,定义整数 $a_k$ 为首项为 $Bk + C$、公差为 $D$、项数为 $N$ 的等差数列中所有项的乘积,即 $a_k = (Bk+C)(Bk+C+D)(Bk+C+2D)\dots(Bk+C+(N-1)D)$。AI (CI翻译)
Find the greatest common divisor, modulo $998244353$, of $a_0, a_1, a_2, \ldots, a_N$.
求 $a_0, a_1, a_2, \ldots, a_N$ 的最大公约数对 $998244353$ 取模后的结果。AI (CI翻译)
You are given $T$ test cases; solve each of them.
给定 $T$ 组测试用例,请分别求出每组测试用例的答案。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \leq T \leq 10^5$$1 \leq N, B, C, D \leq 10^6$- All input values are integers.
$1 \leq T \leq 10^5$$1 \leq N, B, C, D \leq 10^6$- 所有输入值均为整数。
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 is given in the following format:
每组测试用例按以下格式给出:AI (CI翻译)
N B C D
N B C DAI (CI翻译)
Output
输出格式
AI (CI翻译)Output $T$ lines. The $i$-th line should contain the answer to $\mathrm{case}_i$.
输出 $T$ 行。第 $i$ 行应包含 $\mathrm{case}_i$ 的答案。AI (CI翻译)
样例
3
3 1 1 1
4 2 2 6
2026 3 22 216
6
128
114347907
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。