問題一覧 > 通常問題

No.2452 Incline

レベル : / AI推定難易度 : 1725 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 74
作問者 : srjywrdnprkt / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 9856 / 自分の提出
問題文最終更新日: 2023-09-02 00:07:47
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 403 (順位表) の他の問題:

Problem Statement

Find the number, modulo $998244353$, of arithmetic sequences $A=(A_1, \cdots, A_N)$ of length $N$ that satisfy all of the following conditions.

  • For every integer $i$ satisfying $1\leq i\leq N-1$, $A_i$ is an integer between $0$ and $M$, inclusive.
  • $A_N$ is an integer between $L$ and $R$, inclusive.
You are given $T$ test cases; find the answer for each of them.

Input

$T$
$case_1$
$\vdots$
$case_T$
Here, $case_i$ denotes the $i$-th test case. Each test case is given in the following format.
$N\ M\ L\ R$

All input values are integers and satisfy the following constraints.

  • $1\leq T\leq 10^5$
  • $2\leq N \leq 10^{18}$
  • $0\leq M \leq 10^{18}$
  • $0\leq L \leq R \leq M$

Output

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

Sample

Sample 1
Input
3
3 5 2 3
2 1000000000000000000 0 1000000000000000000
1000000000000000000 0 0 0
Output
6
866938593
1

For the first test case, the following $6$ sequences satisfy the conditions: $(0, 1, 2), (1, 2, 3), (2, 2, 2), (3, 3, 3), (4, 3, 2), (5, 4, 3)$.

For the second test case, there are $1000000000000000002000000000000000001$ arithmetic sequences satisfying the conditions. The answer is this number modulo $998244353$, which is $866938593$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。