結果

問題 No.2023 Tiling is Fun
ユーザー CleyLCleyL
提出日時 2023-06-06 11:15:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 73,292 KB
実行使用メモリ 7,756 KB
最終ジャッジ日時 2023-08-28 10:39:04
合計ジャッジ時間 2,184 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,680 KB
testcase_01 AC 9 ms
7,672 KB
testcase_02 AC 9 ms
7,524 KB
testcase_03 AC 9 ms
7,680 KB
testcase_04 AC 9 ms
7,528 KB
testcase_05 AC 9 ms
7,736 KB
testcase_06 AC 9 ms
7,568 KB
testcase_07 AC 9 ms
7,628 KB
testcase_08 AC 9 ms
7,564 KB
testcase_09 AC 9 ms
7,576 KB
testcase_10 AC 9 ms
7,640 KB
testcase_11 AC 9 ms
7,756 KB
testcase_12 AC 9 ms
7,736 KB
testcase_13 AC 9 ms
7,676 KB
testcase_14 AC 9 ms
7,708 KB
testcase_15 AC 9 ms
7,528 KB
testcase_16 AC 9 ms
7,536 KB
testcase_17 AC 9 ms
7,700 KB
testcase_18 AC 9 ms
7,576 KB
testcase_19 AC 8 ms
7,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

const long long MOD = 998244353;

template <long long mod>
struct Combination {
  long long n_max;
  vector<long long> fac, inv, finv;
  Combination(int n):n_max(n), fac(n+1,1), inv(n+1,1), finv(n+1,1){
    for(int i = 2; n > i; i++){
      fac[i] = (fac[i-1]*i)%mod;
      inv[i] = mod-((inv[mod%i]*(mod/i))%mod);
      finv[i] = (finv[i-1]*inv[i])%mod;
    }
  }

  long long C(int n, int r){
    if(n < r)return 0;
    if(n > n_max)return 0;
    return (((fac[n]*finv[r])%mod)*finv[n-r])%mod;
  }

  long long P(int n, int r){
    if(n < r)return 0;
    if(n > n_max)return 0;
    return (fac[n]*finv[n-r])%mod;
  }

  long long H(int n, int r){
    if(n==0 && r==0)return 1;
    return C(n+r-1, r);
  }
};
using comb = Combination<MOD>;
int main(){
  comb A(200000);
  int a,b;cin>>a>>b;
  cout << A.C(a+b-2,b-1) << endl;
}
0