結果
| 問題 | 
                            No.2132 1 or X Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             とりゐ
                         | 
                    
| 提出日時 | 2022-11-25 21:47:31 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 298 bytes | 
| コンパイル時間 | 345 ms | 
| コンパイル使用メモリ | 82,084 KB | 
| 実行使用メモリ | 76,780 KB | 
| 最終ジャッジ日時 | 2024-10-02 04:23:27 | 
| 合計ジャッジ時間 | 7,324 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | WA * 11 | 
ソースコード
mod=998244353
def solve():
  n,x=map(int,input().split())
  if x%2==1:
    lose=n//2
    print((n-lose)%mod)
    return
  lose=(n//(2*(x+1))*x)
  n%=(2*(x+1))
  lose+=min(x//2,n//2+1)
  n-=x+1
  lose+=max(0,min(x//2,n//2+1))
  ans=n+1-lose
  print(ans%mod)
for _ in range(int(input())):
  solve()
            
            
            
        
            
とりゐ