結果

問題 No.2132 1 or X Game
ユーザー 👑 chro_96chro_96
提出日時 2022-11-25 23:11:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 28,032 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-07-25 11:19:11
合計ジャッジ時間 4,121 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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/(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;
}
0