結果

問題 No.2452 Incline
ユーザー hiro1729hiro1729
提出日時 2023-09-01 21:57:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2025-01-03 08:29:54
合計ジャッジ時間 7,458 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def floor_sum(n, m, a, b):
	ans = 0
	while True:
		if a >= m:
			ans += (n * (n - 1) >> 1) * (a // m)
			a %= m
		if b >= m:
			ans += n * (b // m)
			b %= m
		y = a * n + b
		if y < m:
			return ans
		n, b, m, a = y // m, y % m, a, m
for _ in range(int(input())):
	n, m, l, r = map(int, input().split())
	l += n - 2
	ans = m + 1
	ans += floor_sum(r + 1, n - 1, 1, 0)
	ans -= floor_sum(l + 1, n - 1, 1, 0) - floor_sum(l - m, n - 1, 1, 0)
	print(ans % 998244353)
0