結果

問題 No.2452 Incline
ユーザー fiblonariafiblonaria
提出日時 2023-09-05 14:42:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 441 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 78,816 KB
最終ジャッジ日時 2023-09-05 14:42:57
合計ジャッジ時間 4,632 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,292 KB
testcase_01 AC 76 ms
71,368 KB
testcase_02 AC 78 ms
71,592 KB
testcase_03 AC 436 ms
78,816 KB
testcase_04 AC 433 ms
77,760 KB
testcase_05 AC 441 ms
78,592 KB
testcase_06 AC 420 ms
78,660 KB
testcase_07 AC 435 ms
78,444 KB
testcase_08 AC 354 ms
78,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x, N):
	if x == -1:
		return 0
	q = x // (N - 1)
	r = x % (N - 1)
	return (N - 1) * q * (q - 1) // 2 + q * (r + 1)

def solve(N, M, L, R):
	return f(R, N) - f(L - 1, N) + f(M - L, N) - f(M - R - 1, N) + R - L + 1

T = int(input())
for i in range(T):
	N, M, L, R = map(int, input().split())
	print(solve(N, M, L, R) % 998244353)
0