結果

問題 No.2132 1 or X Game
ユーザー 👑 rin204
提出日時 2023-12-29 17:10:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 597 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,596 KB
実行使用メモリ 76,772 KB
最終ジャッジ日時 2024-09-27 16:16:49
合計ジャッジ時間 10,460 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

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