結果

問題 No.2132 1 or X Game
ユーザー とりゐとりゐ
提出日時 2022-11-25 21:50:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 349 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 77,156 KB
最終ジャッジ日時 2024-04-10 03:03:36
合計ジャッジ時間 8,634 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,372 KB
testcase_01 WA -
testcase_02 AC 587 ms
76,628 KB
testcase_03 WA -
testcase_04 AC 549 ms
76,108 KB
testcase_05 AC 560 ms
76,720 KB
testcase_06 AC 530 ms
76,428 KB
testcase_07 AC 548 ms
76,788 KB
testcase_08 AC 572 ms
76,736 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353

def solve():
  n,x=map(int,input().split())
  N=n
  if x%2==1:
    lose=n//2
    print((n-lose)%mod)
    return
  lose=(n//(2*(x+1)))*x
  #print(lose)
  n%=(2*(x+1))
  lose+=min(x//2,n//2+1)
  #print(lose)
  n-=x+1
  lose+=max(0,min(x//2,n//2+1))
  #print(lose)
  ans=N+1-lose
  print(ans%mod)

for _ in range(int(input())):
  solve()
0