結果

問題 No.1927 AB-CD
ユーザー 遭難者遭難者
提出日時 2022-03-28 13:09:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 22,988 KB
最終ジャッジ日時 2024-04-24 19:29:08
合計ジャッジ時間 4,808 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 29 ms
10,624 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 AC 181 ms
19,960 KB
testcase_05 AC 176 ms
19,500 KB
testcase_06 AC 166 ms
19,424 KB
testcase_07 AC 156 ms
18,504 KB
testcase_08 AC 43 ms
11,520 KB
testcase_09 AC 203 ms
20,300 KB
testcase_10 AC 142 ms
18,012 KB
testcase_11 AC 164 ms
19,072 KB
testcase_12 AC 90 ms
14,592 KB
testcase_13 AC 110 ms
15,232 KB
testcase_14 AC 37 ms
11,136 KB
testcase_15 AC 61 ms
12,544 KB
testcase_16 AC 164 ms
19,328 KB
testcase_17 AC 128 ms
17,024 KB
testcase_18 AC 142 ms
17,408 KB
testcase_19 AC 148 ms
18,048 KB
testcase_20 AC 194 ms
21,132 KB
testcase_21 AC 153 ms
18,288 KB
testcase_22 AC 82 ms
13,952 KB
testcase_23 AC 205 ms
21,664 KB
testcase_24 AC 225 ms
22,856 KB
testcase_25 AC 226 ms
22,984 KB
testcase_26 AC 225 ms
22,988 KB
testcase_27 AC 29 ms
10,752 KB
testcase_28 AC 29 ms
10,752 KB
testcase_29 AC 29 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
x = y = 0
for i in s:
    if i == 'A' or i == 'B':
        x += 1
    if i == 'C' or i == 'D':
        y += 1
mod = 998244353
fac = [1] * (n + 1)
for i in range(n):
    fac[i + 1] = (i + 1) * fac[i] % mod
ans = fac[n] * pow(fac[x], mod - 2, mod) * pow(fac[y], mod - 2, mod)
print(ans % mod)
0