結果

問題 No.1927 AB-CD
ユーザー Nzt3Nzt3
提出日時 2022-09-24 23:34:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 200,212 KB
実行使用メモリ 10,504 KB
最終ジャッジ日時 2023-08-24 00:39:11
合計ジャッジ時間 3,608 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 11 ms
8,716 KB
testcase_05 AC 11 ms
8,460 KB
testcase_06 AC 10 ms
8,524 KB
testcase_07 AC 10 ms
7,888 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 11 ms
9,044 KB
testcase_10 AC 9 ms
7,372 KB
testcase_11 AC 9 ms
8,208 KB
testcase_12 AC 6 ms
5,396 KB
testcase_13 AC 5 ms
5,940 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 10 ms
8,260 KB
testcase_17 AC 7 ms
6,924 KB
testcase_18 AC 8 ms
7,096 KB
testcase_19 AC 8 ms
7,660 KB
testcase_20 AC 11 ms
9,480 KB
testcase_21 AC 9 ms
7,716 KB
testcase_22 AC 4 ms
5,172 KB
testcase_23 AC 12 ms
9,824 KB
testcase_24 AC 14 ms
10,428 KB
testcase_25 AC 13 ms
10,504 KB
testcase_26 AC 13 ms
10,500 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

const int mod=998244353;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  string S;
  cin>>N>>S;
  int AB=0,CD=0;
  vector<long long>inv(N+1),fac(N+1),invf(N+1);
  fac[0]=inv[0]=invf[0]=1;
  fac[1]=inv[1]=invf[1]=1;
  for(int i=2;i<=N;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
    invf[i]=invf[i-1]*inv[i]%mod;
  }
  for(int i=0;i<=N;i++){
    switch(S[i]){
      case 'A':++AB;break;
      case 'B':++AB;break;
      case 'C':++CD;break;
      case 'D':++CD;break;
    }
  }
  cout<<fac[N]*invf[AB]%mod*invf[CD]%mod<<'\n';
}
0