結果

問題 No.1927 AB-CD
ユーザー monnumonnu
提出日時 2022-05-06 23:27:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 4,595 ms
コンパイル使用メモリ 226,168 KB
実行使用メモリ 10,840 KB
最終ジャッジ日時 2023-09-20 06:32:59
合計ジャッジ時間 5,855 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
10,448 KB
testcase_01 AC 9 ms
10,372 KB
testcase_02 AC 9 ms
10,408 KB
testcase_03 AC 9 ms
10,544 KB
testcase_04 AC 13 ms
10,612 KB
testcase_05 AC 13 ms
10,500 KB
testcase_06 AC 13 ms
10,556 KB
testcase_07 AC 12 ms
10,696 KB
testcase_08 AC 10 ms
10,564 KB
testcase_09 AC 14 ms
10,696 KB
testcase_10 AC 12 ms
10,600 KB
testcase_11 AC 12 ms
10,568 KB
testcase_12 AC 10 ms
10,564 KB
testcase_13 AC 10 ms
10,672 KB
testcase_14 AC 9 ms
10,516 KB
testcase_15 AC 10 ms
10,816 KB
testcase_16 AC 13 ms
10,828 KB
testcase_17 AC 11 ms
10,508 KB
testcase_18 AC 12 ms
10,840 KB
testcase_19 AC 12 ms
10,572 KB
testcase_20 AC 14 ms
10,640 KB
testcase_21 AC 12 ms
10,596 KB
testcase_22 AC 10 ms
10,680 KB
testcase_23 AC 14 ms
10,780 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 9 ms
10,380 KB
testcase_28 AC 8 ms
10,368 KB
testcase_29 AC 8 ms
10,460 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