結果

問題 No.2132 1 or X Game
ユーザー 👑 chro_96chro_96
提出日時 2022-11-25 22:42:19
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 28,416 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-25 10:53:17
合計ジャッジ時間 3,146 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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/(2LL*x+1LL))*(x+1LL);
      if (n%(2LL*x+1LL) < x) {
        ans += (n%(2LL*x+1LL)+1LL)/2LL;
      } else {
        ans += 1LL+(n%(2LL*x+1LL)-x)/2LL;
        ans += x/2LL;
      }
      printf("%lld\n", ans%mod_num);
    }
    t--;
  }
  
  return 0;
}
0