結果

問題 No.1927 AB-CD
ユーザー monnumonnu
提出日時 2022-05-06 22:25:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 832 bytes
コンパイル時間 4,035 ms
コンパイル使用メモリ 227,112 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2023-09-20 03:25:22
合計ジャッジ時間 5,501 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
10,488 KB
testcase_01 AC 8 ms
10,500 KB
testcase_02 AC 8 ms
10,708 KB
testcase_03 AC 9 ms
10,380 KB
testcase_04 AC 13 ms
10,688 KB
testcase_05 AC 12 ms
10,632 KB
testcase_06 AC 12 ms
10,464 KB
testcase_07 AC 12 ms
10,544 KB
testcase_08 AC 9 ms
10,676 KB
testcase_09 AC 13 ms
10,672 KB
testcase_10 AC 12 ms
10,672 KB
testcase_11 AC 12 ms
10,672 KB
testcase_12 AC 10 ms
10,552 KB
testcase_13 AC 11 ms
10,468 KB
testcase_14 AC 9 ms
10,636 KB
testcase_15 AC 9 ms
10,592 KB
testcase_16 AC 12 ms
10,620 KB
testcase_17 AC 11 ms
10,464 KB
testcase_18 AC 12 ms
10,532 KB
testcase_19 AC 13 ms
10,468 KB
testcase_20 AC 13 ms
10,560 KB
testcase_21 AC 13 ms
10,724 KB
testcase_22 AC 10 ms
10,556 KB
testcase_23 AC 13 ms
10,628 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 8 ms
10,596 KB
testcase_28 AC 8 ms
10,340 KB
testcase_29 AC 9 ms
10,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000
#define MOD 998244353
#define MAX 300000

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

void COMinit(){
  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 COM(int n,int k){
  static bool flag=false;
  if(!flag){
    COMinit();
    flag=true;
  }

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int cnt=0;
  for(int i=0;i<N;i++){
    if(S[i]=='A'||S[i]=='B'){
      cnt++;
    }
  }
  ll ans=COM(N,cnt);
  cout<<ans<<endl;
}
0