結果

問題 No.2452 Incline
ユーザー 遭難者遭難者
提出日時 2023-09-02 01:36:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 78,296 KB
最終ジャッジ日時 2023-09-02 01:36:09
合計ジャッジ時間 3,366 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,160 KB
testcase_01 AC 66 ms
71,640 KB
testcase_02 AC 66 ms
71,404 KB
testcase_03 AC 204 ms
78,296 KB
testcase_04 AC 221 ms
78,104 KB
testcase_05 AC 200 ms
78,080 KB
testcase_06 AC 192 ms
78,080 KB
testcase_07 AC 204 ms
78,120 KB
testcase_08 AC 143 ms
77,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
input = stdin.readline
MOD = 998244353
def f(r, n):
    r1, r2 = r // n, r % n
    ans = r1 * (r2 + 1) + n * (r1 - 1) * r1 // 2
    return ans % MOD
def main():
    n, m, l, r = map(int, input().split())
    n -= 1
    m += 1
    l -= 1
    ans = 0
    ans += f(r, n) - f(l, n)
    ans -= f(r - m, n) - f(l - m, n)
    print(ans % MOD)
for _ in range(int(input())):
    main()
0