結果

問題 No.2023 Tiling is Fun
ユーザー umezoumezo
提出日時 2022-07-29 21:48:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 199,508 KB
実行使用メモリ 8,548 KB
最終ジャッジ日時 2023-09-26 20:26:52
合計ジャッジ時間 2,945 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,516 KB
testcase_01 AC 6 ms
8,312 KB
testcase_02 AC 7 ms
8,296 KB
testcase_03 AC 6 ms
8,300 KB
testcase_04 AC 6 ms
8,312 KB
testcase_05 AC 6 ms
8,300 KB
testcase_06 AC 6 ms
8,296 KB
testcase_07 AC 6 ms
8,320 KB
testcase_08 AC 6 ms
8,300 KB
testcase_09 AC 6 ms
8,300 KB
testcase_10 AC 6 ms
8,292 KB
testcase_11 AC 6 ms
8,428 KB
testcase_12 AC 6 ms
8,384 KB
testcase_13 AC 7 ms
8,324 KB
testcase_14 AC 6 ms
8,384 KB
testcase_15 AC 6 ms
8,296 KB
testcase_16 AC 6 ms
8,392 KB
testcase_17 AC 7 ms
8,364 KB
testcase_18 AC 7 ms
8,256 KB
testcase_19 AC 7 ms
8,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
const int MAX=210000;
const int MOD=998244353;

ll fac[MAX],finv[MAX],inv[MAX];

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;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;
  }
}

ll nCr(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll a,b;
  cin>>a>>b;
  
  init();
  
  cout<<nCr(a+b-2,a-1)<<endl;
  
  
    
  return 0;
}
0