AtCoder Beginner Contest 381
G
Fibonacci Product
AtCoder
⌀ 3313
原题
翻译中…

Problem Statement

翻译中…

Define a sequence $a_1, a_2, a_3, \dots$ as follows:

翻译中…

$a_n = \begin{cases} x & (n=1) \\ y & (n=2) \\ a_{n-1} + a_{n-2} & (n \geq 3) \\ \end{cases}$

翻译中…

Find $\left( \displaystyle \prod_{i=1}^N a_i \right) \bmod{998244353}$.

翻译中…

You are given $T$ test cases to solve.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 5$
  • $1 \leq N \leq 10^{18}$
  • $0 \leq x \leq 998244352$
  • $0 \leq y \leq 998244352$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format. Here, $\mathrm{case}_i$ denotes the $i$-th test case.

翻译中…

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

翻译中…

Each test case is given in the following format:

翻译中…

N x y

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain the answer to the $i$-th test case.

翻译中…

样例

Input #1
3
5 1 1
2024 11 22
1000000000000000000 12345 6789
Output #1
30
577322229
726998219
For the first test case, the elements of the sequence are $1, 1, 2, 3, 5, 8, \dots$. Thus, the answer is $(1 \times 1 \times 2 \times 3 \times 5) \bmod{998244353} = 30$.
题目信息
题号
abc381_g
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。