結果

問題 No.2132 1 or X Game
ユーザー 👑 rin204rin204
提出日時 2023-12-29 17:10:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 685 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,260 KB
最終ジャッジ日時 2023-12-29 17:10:29
合計ジャッジ時間 11,117 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 652 ms
75,996 KB
testcase_02 AC 685 ms
75,992 KB
testcase_03 AC 587 ms
76,004 KB
testcase_04 AC 633 ms
75,992 KB
testcase_05 AC 615 ms
76,260 KB
testcase_06 AC 612 ms
76,260 KB
testcase_07 AC 645 ms
75,992 KB
testcase_08 AC 614 ms
76,000 KB
testcase_09 AC 598 ms
76,260 KB
testcase_10 AC 587 ms
76,000 KB
testcase_11 AC 617 ms
76,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353


def solve(n, x):
    if x % 2 == 1:
        ans = (n + 1) // 2
    elif n < x:
        ans = (n + 1) // 2
    else:
        ans = x // 2
        n -= x
        ans += n // (x + 3) * ((x + 4) // 2)
        n %= x + 3
        ans += n // 2 + 1
    print(ans % MOD)


for _ in range(int(input())):
    solve(*map(int, input().split()))
0