No.2452 Incline
タグ : / 解いたユーザー数 74
作問者 :
srjywrdnprkt
/ テスター :
👑 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.
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もしくは右上の雲マークをクリックしてアカウントを作成してください。