結果

問題 No.1927 AB-CD
ユーザー pockynypockyny
提出日時 2022-05-06 21:33:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 818 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 70,492 KB
実行使用メモリ 6,216 KB
最終ジャッジ日時 2023-09-20 02:26:43
合計ジャッジ時間 5,174 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,692 KB
testcase_01 AC 4 ms
5,700 KB
testcase_02 AC 5 ms
5,696 KB
testcase_03 AC 4 ms
5,700 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 5 ms
5,740 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 7 ms
5,940 KB
testcase_13 RE -
testcase_14 AC 6 ms
5,772 KB
testcase_15 AC 6 ms
5,872 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 7 ms
5,952 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 5 ms
5,748 KB
testcase_28 AC 5 ms
5,748 KB
testcase_29 AC 5 ms
5,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
using ll = long long;
const int MX = 100010;
ll f[MX],inv[MX],fi[MX];
constexpr ll mod = 998244353;
void solve(){
    inv[1] = 1;
    for(int i=2;i<MX;i++){
        inv[i] = mod - (mod/i)*inv[mod%i]%mod;
    }
    f[0] = fi[0] = 1;
    for(int i=1;i<MX;i++){
        f[i] = f[i-1]*i%mod;
        fi[i] = fi[i-1]*inv[i]%mod;
    }
}

ll nck(ll n, ll k){
    if(n<0 || k<0 || n<k) return 0;
    return f[n]*fi[k]%mod*fi[n-k]%mod;
}

ll pw(ll a,ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

int main(){
    int i,n; cin >> n;
    string s; cin >> s;
    int k = 0;
    for(i=0;i<n;i++){
        if(s[i]=='A' || s[i]=='B') k++;
    }
    solve();
    cout << nck(n,k) << endl;
}
0