結果

問題 No.2132 1 or X Game
ユーザー KudeKude
提出日時 2022-11-25 22:07:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 575 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,800 KB
最終ジャッジ日時 2024-04-10 03:16:34
合計ジャッジ時間 8,076 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,848 KB
testcase_01 AC 575 ms
76,440 KB
testcase_02 AC 559 ms
76,196 KB
testcase_03 AC 515 ms
76,392 KB
testcase_04 AC 524 ms
76,112 KB
testcase_05 AC 529 ms
76,228 KB
testcase_06 AC 532 ms
76,792 KB
testcase_07 AC 526 ms
76,344 KB
testcase_08 AC 545 ms
76,800 KB
testcase_09 AC 484 ms
76,368 KB
testcase_10 AC 520 ms
76,172 KB
testcase_11 AC 521 ms
76,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
for _ in range(int(input())):
    n, x = map(int, input().split())
    n += 1
    if x % 2:
        print(n // 2 % mod)
    else:
        period = x + 3
        cnt = (period + 1) // 2
        ans = n // period * cnt
        n %= period
        if n <= x:
            ans += n // 2
        else:
            ans += x // 2 + 1
        print(ans % mod)
0