結果

問題 No.1927 AB-CD
ユーザー lloyzlloyz
提出日時 2022-06-12 00:28:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 97,208 KB
最終ジャッジ日時 2023-10-23 16:53:20
合計ジャッジ時間 5,342 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,552 KB
testcase_01 AC 38 ms
53,552 KB
testcase_02 AC 38 ms
53,552 KB
testcase_03 AC 38 ms
53,552 KB
testcase_04 AC 89 ms
92,208 KB
testcase_05 AC 85 ms
91,456 KB
testcase_06 AC 87 ms
90,980 KB
testcase_07 AC 83 ms
89,308 KB
testcase_08 AC 48 ms
65,020 KB
testcase_09 AC 93 ms
92,396 KB
testcase_10 AC 81 ms
88,148 KB
testcase_11 AC 84 ms
90,276 KB
testcase_12 AC 58 ms
74,072 KB
testcase_13 AC 61 ms
74,712 KB
testcase_14 AC 47 ms
64,224 KB
testcase_15 AC 51 ms
68,120 KB
testcase_16 AC 85 ms
90,548 KB
testcase_17 AC 83 ms
80,044 KB
testcase_18 AC 81 ms
87,464 KB
testcase_19 AC 82 ms
88,604 KB
testcase_20 AC 93 ms
94,056 KB
testcase_21 AC 81 ms
89,120 KB
testcase_22 AC 56 ms
71,384 KB
testcase_23 AC 95 ms
95,208 KB
testcase_24 AC 101 ms
97,208 KB
testcase_25 AC 100 ms
97,208 KB
testcase_26 AC 100 ms
97,208 KB
testcase_27 AC 39 ms
53,552 KB
testcase_28 AC 39 ms
53,552 KB
testcase_29 AC 39 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

n = int(input())
S = list(input())
mod = 998244353

fact = [1] * (n + 1)
inv = [1] * (n + 1)
finv = [1] * (n + 1)
for i in range(2, n + 1):
    fact[i] = fact[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod
def comb(x, y):
    return (fact[x] * finv[y] % mod) * finv[x - y] % mod

counter = Counter(S)
print(comb(n, counter['A'] + counter['B']))
0