結果

問題 No.2132 1 or X Game
ユーザー shotoyooshotoyoo
提出日時 2022-11-25 23:49:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 82,644 KB
実行使用メモリ 78,260 KB
最終ジャッジ日時 2024-04-10 04:48:23
合計ジャッジ時間 4,861 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,648 KB
testcase_01 AC 222 ms
78,020 KB
testcase_02 AC 219 ms
77,692 KB
testcase_03 AC 186 ms
77,676 KB
testcase_04 AC 195 ms
77,752 KB
testcase_05 AC 202 ms
77,940 KB
testcase_06 AC 206 ms
77,960 KB
testcase_07 AC 191 ms
77,900 KB
testcase_08 AC 189 ms
77,984 KB
testcase_09 AC 153 ms
78,260 KB
testcase_10 AC 174 ms
77,740 KB
testcase_11 AC 173 ms
78,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
input = lambda : sys.stdin.readline().rstrip()


write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda : list(map(int, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()]
def debug(_l_):
    for s in _l_.split():
        print(f"{s}={eval(s)}", end=" ")
    print()
def dlist(*l, fill=0):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]

t = II()
M = 998244353
for _ in range(t):
    n,x = list(map(int, input().split()))
    n += 1
    if x%2:
        ans = n//2
    else:
        if n<=x:
            ans = n//2
        else:
            d,m = divmod((n-x), x+3)
            ans = x//2 + (x//2+2)*d + (m+1)//2
    print(ans%M)
0