結果

問題 No.2452 Incline
ユーザー ntudantuda
提出日時 2023-09-02 01:42:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 79,296 KB
最終ジャッジ日時 2023-09-02 01:42:27
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

MOD = 998244353
def calc(n, X, Y):
    x = -(-X // n) * n
    y = Y // n * n
    if x > y:
        return (Y - X + 1) * Y // n
    else:
        tmp = (x - X) * x // n
        tmp += (Y - y + 1) * y // n
        tmp += n * (y - x) * (x + y - 1) // 2
        return tmp % MOD

def solve():
    N, M, L, R = map(int, input().split())
    N1 = N - 1
    ans = R - L + 1
    ans += calc(N - 1, L, R)
    ans += calc(N - 1, M - R, M - L)
    ans %= MOD
    print(ans)

T = int(input())
for t in range(T):
    solve()
0