結果

問題 No.2132 1 or X Game
コンテスト
ユーザー rin204
提出日時 2023-12-29 17:10:18
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 387 ms / 2,000 ms
コード長 351 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 178 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 81,836 KB
最終ジャッジ日時 2026-04-14 10:41:15
合計ジャッジ時間 9,207 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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