結果

問題 No.2452 Incline
ユーザー ニックネームニックネーム
提出日時 2023-09-01 22:44:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,410 ms / 2,000 ms
コード長 273 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-09-01 22:44:13
合計ジャッジ時間 10,024 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,784 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 16 ms
7,832 KB
testcase_03 AC 1,352 ms
7,948 KB
testcase_04 AC 1,377 ms
7,828 KB
testcase_05 AC 1,331 ms
7,828 KB
testcase_06 AC 1,410 ms
7,784 KB
testcase_07 AC 1,383 ms
7,756 KB
testcase_08 AC 1,268 ms
7,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(n,x):
    q,r = divmod(max(x,0),n-1)
    return (2*r+2+(n-1)*(q-1))*q//2
def g(n,m,x): return f(n,x)-f(n,x-m-1)
for _ in range(int(input())):
    n,m,l,r = map(int,input().split())
    print((g(n,m,r)-g(n,m,l-1)+g(n,m,m-l)-g(n,m,m-r-1)+max(min(m,r)-l+1,0))%998244353)
0