結果
問題 | No.2452 Incline |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2023-09-01 23:03:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 509 ms / 2,000 ms |
コード長 | 581 bytes |
コンパイル時間 | 444 ms |
コンパイル使用メモリ | 87,228 KB |
実行使用メモリ | 80,004 KB |
最終ジャッジ日時 | 2023-09-01 23:03:15 |
合計ジャッジ時間 | 4,592 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,360 KB |
testcase_01 | AC | 72 ms
71,384 KB |
testcase_02 | AC | 71 ms
71,352 KB |
testcase_03 | AC | 509 ms
80,004 KB |
testcase_04 | AC | 404 ms
78,624 KB |
testcase_05 | AC | 438 ms
78,756 KB |
testcase_06 | AC | 410 ms
79,104 KB |
testcase_07 | AC | 402 ms
78,400 KB |
testcase_08 | AC | 405 ms
78,680 KB |
ソースコード
mod = 998244353 def f(x,n): # print(f"x = {x} n = {n}") if x < n-1: return 0 first = x - (n-1) + 1 ## y = -n * x + first last = first % (n-1) num = (first-last)//(n-1) + 1 ans = (first+last)*num//2%mod # print(f"first = {first} last = {last} num = {num} ans = {ans}") return ans def solve(): n,m,l,r = map(int,input().split()) ans = 0 # dif = 0 ans += (r-l+1) ans += f(r,n) - f(l-1,n) ans += f(m-l,n) - f(m-r-1,n) ans %= mod return ans t = int(input()) for _ in range(t): print(solve())