結果

問題 No.2511 Mountain Sequence
ユーザー 👑 chro_96chro_96
提出日時 2023-10-20 22:07:30
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,085 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 30,760 KB
実行使用メモリ 8,204 KB
最終ジャッジ日時 2023-10-20 22:07:33
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,204 KB
testcase_01 AC 4 ms
8,204 KB
testcase_02 AC 6 ms
8,204 KB
testcase_03 AC 4 ms
8,204 KB
testcase_04 AC 5 ms
8,204 KB
testcase_05 AC 5 ms
8,204 KB
testcase_06 AC 6 ms
8,204 KB
testcase_07 AC 7 ms
8,204 KB
testcase_08 AC 4 ms
8,204 KB
testcase_09 AC 4 ms
8,204 KB
testcase_10 AC 8 ms
8,204 KB
testcase_11 AC 8 ms
8,204 KB
testcase_12 AC 4 ms
8,204 KB
testcase_13 AC 8 ms
8,204 KB
testcase_14 AC 8 ms
8,204 KB
testcase_15 AC 8 ms
8,204 KB
testcase_16 AC 8 ms
8,204 KB
testcase_17 AC 8 ms
8,204 KB
testcase_18 AC 8 ms
8,204 KB
testcase_19 AC 7 ms
8,204 KB
testcase_20 AC 8 ms
8,204 KB
testcase_21 AC 8 ms
8,204 KB
testcase_22 AC 8 ms
8,204 KB
testcase_23 AC 5 ms
8,204 KB
testcase_24 AC 5 ms
8,204 KB
testcase_25 AC 8 ms
8,204 KB
testcase_26 AC 4 ms
8,204 KB
testcase_27 AC 6 ms
8,204 KB
testcase_28 AC 3 ms
8,204 KB
testcase_29 AC 8 ms
8,204 KB
testcase_30 AC 8 ms
8,204 KB
testcase_31 AC 8 ms
8,204 KB
testcase_32 AC 8 ms
8,204 KB
testcase_33 AC 8 ms
8,204 KB
testcase_34 AC 8 ms
8,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

long long power_mod (long long a, long long b, long long mod_num) {
  long long ans = 1LL;
  
  if (b > 0LL) {
    ans = power_mod(a, b/2LL, mod_num);
    ans = (ans * ans) % mod_num;
    if (b%2LL == 1LL) {
      ans = (ans * (a % mod_num)) % mod_num;
    }
  }
  
  return ans;
}

int main () {
  int n = 0;
  int m = 0;
  
  int res = 0;
  
  long long ans = 0LL;
  long long mod_num = 998244353LL;
  
  long long fact[400000] = {};
  long long invf[400000] = {};
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  
  fact[0] = 1LL;
  for (int i = 0; i < 2*m-2; i++) {
    fact[i+1] = fact[i];
    fact[i+1] *= (long long)(i+1);
    fact[i+1] %= mod_num;
  }
  
  invf[2*m-2] = power_mod(fact[2*m-2], mod_num-2LL, mod_num);
  for (int i = 2*m-2; i > 0; i--) {
    invf[i-1] = invf[i];
    invf[i-1] *= (long long)i;
    invf[i-1] %= mod_num;
  }
  
  for (int i = 0; i < m; i++) {
    if (2*i >= n-1) {
      long long tmp = (fact[2*i]*invf[n-1])%mod_num;
      ans += (tmp*invf[2*i-n+1])%mod_num;
    }
  }
  
  printf("%lld\n", ans%mod_num);
  return 0;
}
0