結果

問題 No.1927 AB-CD
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-29 19:58:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 10,772 KB
最終ジャッジ日時 2023-10-21 00:11:04
合計ジャッジ時間 2,883 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,140 KB
testcase_01 AC 32 ms
10,140 KB
testcase_02 AC 31 ms
10,140 KB
testcase_03 AC 30 ms
10,140 KB
testcase_04 AC 62 ms
10,576 KB
testcase_05 AC 61 ms
10,508 KB
testcase_06 AC 61 ms
10,544 KB
testcase_07 AC 57 ms
10,496 KB
testcase_08 AC 34 ms
10,184 KB
testcase_09 AC 63 ms
10,508 KB
testcase_10 AC 55 ms
10,324 KB
testcase_11 AC 58 ms
10,508 KB
testcase_12 AC 45 ms
10,256 KB
testcase_13 AC 49 ms
10,340 KB
testcase_14 AC 33 ms
10,180 KB
testcase_15 AC 36 ms
10,264 KB
testcase_16 AC 60 ms
10,536 KB
testcase_17 AC 51 ms
10,300 KB
testcase_18 AC 54 ms
10,448 KB
testcase_19 AC 55 ms
10,480 KB
testcase_20 AC 67 ms
10,624 KB
testcase_21 AC 56 ms
10,336 KB
testcase_22 AC 41 ms
10,332 KB
testcase_23 AC 68 ms
10,772 KB
testcase_24 AC 72 ms
10,508 KB
testcase_25 AC 72 ms
10,508 KB
testcase_26 AC 75 ms
10,508 KB
testcase_27 AC 31 ms
10,140 KB
testcase_28 AC 29 ms
10,140 KB
testcase_29 AC 30 ms
10,140 KB
権限があれば一括ダウンロードができます

ソースコード

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