結果

問題 No.2132 1 or X Game
ユーザー 👑 chro_96chro_96
提出日時 2022-11-25 23:11:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 04:15:47
合計ジャッジ時間 3,301 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 98 ms
6,944 KB
testcase_02 AC 97 ms
6,944 KB
testcase_03 AC 79 ms
6,940 KB
testcase_04 AC 96 ms
6,944 KB
testcase_05 AC 96 ms
6,944 KB
testcase_06 AC 97 ms
6,944 KB
testcase_07 AC 96 ms
6,944 KB
testcase_08 AC 96 ms
6,944 KB
testcase_09 AC 62 ms
6,940 KB
testcase_10 AC 85 ms
6,944 KB
testcase_11 AC 84 ms
6,944 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