結果
| 問題 | 
                            No.2132 1 or X Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             chro_96
                         | 
                    
| 提出日時 | 2022-11-25 23:11:29 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 98 ms / 2,000 ms | 
| コード長 | 602 bytes | 
| コンパイル時間 | 347 ms | 
| コンパイル使用メモリ | 29,184 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-02 05:41:18 | 
| 合計ジャッジ時間 | 3,360 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 11 | 
ソースコード
#include <stdio.h>
int main () {
  int t = 0;
  long long n = 0LL;
  long long x = 0LL;
  
  int res = 0;
  
  long long mod_num = 998244353LL;
  
  res = scanf("%d", &t);
  
  while (t > 0) {
    res = scanf("%lld", &n);
    res = scanf("%lld", &x);
    if (x%2LL == 1LL) {
      printf("%lld\n", ((n+1LL)/2LL)%mod_num);
    } else {
      long long ans = (n/(x+3LL))*(x/2LL+2LL);
      if (n%(x+3LL) < x) {
        ans += (n%(x+3LL)+1LL)/2LL;
      } else {
        ans += 1LL+(n%(x+3LL)-x)/2LL;
        ans += x/2LL;
      }
      printf("%lld\n", ans%mod_num);
    }
    t--;
  }
  
  return 0;
}
            
            
            
        
            
chro_96