#P17301. [ICPC 2026 Xi'an I] Unreachable Land

    ID: 17192 Type: RemoteJudge 2000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>ICPC2026省赛/邀请赛西安

[ICPC 2026 Xi'an I] Unreachable Land

题目描述

Yuki dreams of reaching the unreachable land. After years of hard work, only this problem remains before her.

Given three integers a,b,ma, b, m. You need to perform mm rounds of operations. In the ii-th round, you can either set a←a mod (m−i+1)a \leftarrow a \bmod (m - i + 1) or choose not to modify aa. Find the number of ways to make a=ba = b after mm rounds, modulo 998244353998244353.

Two schemes are considered different if and only if there exists some 1≤i≤m1 \le i \le m such that in one scheme you performed a modification in the ii-th round, while in the other you did not. Note that choosing to perform a←a mod (m−i+1)a \leftarrow a \bmod (m - i + 1) is considered a modification, regardless of whether the value of aa changes after the operation.

You once dreamed of reaching the unreachable land that only exists in fairy tales. Now that Yuki has a chance to realize this dream, you must help her.

输入格式

This problem contains multiple test cases.

The first line contains a positive integer tt (1≤t≤105)(1 \le t \le 10^5), representing the number of test cases.

For each test case:

  • A single line contains three integers a,b,ma, b, m (0≤b<m≤a≤2⋅105)(0 \le b < m \le a \le 2 \cdot 10^5).

It is guaranteed that the sum of aa over all test cases does not exceed 2⋅1052 \cdot 10^5.

输出格式

For each test case, output a single line containing an integer representing the answer modulo 998244353998244353.

5
5 0 5
5 2 3
10 1 7
10 6 10
100000 114 514
25
1
14
0
837481226

提示

For the first test case:

  • One valid operation scheme is to perform modifications in the 33-rd and 44-th rounds.
  • Another valid operation scheme is to perform modifications in all rounds from 11 to 55.

For the second test case:

  • The only valid operation scheme is to perform a modification in the 33-rd round.

For the fourth test case:

  • It can be proven that no valid operation scheme exists.