結果

問題 No.1927 AB-CD
ユーザー tktk_snsn
提出日時 2022-05-29 19:58:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-09-21 00:37:34
合計ジャッジ時間 2,896 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def binomial_coefficient(n, r, mod=10**9+7):
    if r < 0 or r > n:
        return 0
    res = 1
    div = 1
    r = min(r, n - r)
    for i in range(r):
        res = res * (n - i) % mod
        div = div * (i + 1) % mod
    return res * pow(div, mod-2, mod) % mod


N = int(input())
S = input()

AB = S.count("A") + S.count("B")
print(binomial_coefficient(N, AB, mod))
0