結果

問題 No.2132 1 or X Game
ユーザー KudeKude
提出日時 2022-11-25 22:07:02
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 646 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 78,916 KB
最終ジャッジ日時 2023-07-25 10:13:12
合計ジャッジ時間 9,478 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,348 KB
testcase_01 AC 646 ms
78,672 KB
testcase_02 AC 634 ms
78,484 KB
testcase_03 AC 605 ms
77,616 KB
testcase_04 AC 608 ms
78,648 KB
testcase_05 AC 623 ms
78,544 KB
testcase_06 AC 619 ms
78,648 KB
testcase_07 AC 618 ms
78,744 KB
testcase_08 AC 633 ms
78,740 KB
testcase_09 AC 580 ms
78,916 KB
testcase_10 AC 611 ms
78,692 KB
testcase_11 AC 608 ms
78,480 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