結果

問題 No.2452 Incline
ユーザー hiro1729hiro1729
提出日時 2023-09-01 22:02:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 10,836 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-09-01 22:02:24
合計ジャッジ時間 6,792 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,984 KB
testcase_01 AC 15 ms
7,864 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
	ans += floor_sum(l - m, n - 1, 1, 0)
	print(ans % 998244353)
0