結果

問題 No.1927 AB-CD
ユーザー sotanishysotanishy
提出日時 2022-05-06 21:29:57
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 77,260 KB
最終ジャッジ日時 2023-09-20 02:22:56
合計ジャッジ時間 4,335 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,276 KB
testcase_01 AC 73 ms
71,572 KB
testcase_02 AC 72 ms
71,292 KB
testcase_03 AC 72 ms
71,288 KB
testcase_04 AC 89 ms
76,888 KB
testcase_05 AC 88 ms
76,928 KB
testcase_06 AC 88 ms
76,920 KB
testcase_07 AC 84 ms
76,416 KB
testcase_08 AC 79 ms
76,128 KB
testcase_09 AC 87 ms
76,892 KB
testcase_10 AC 85 ms
76,152 KB
testcase_11 AC 86 ms
76,856 KB
testcase_12 AC 80 ms
75,848 KB
testcase_13 AC 81 ms
76,084 KB
testcase_14 AC 78 ms
76,036 KB
testcase_15 AC 80 ms
76,208 KB
testcase_16 AC 86 ms
76,732 KB
testcase_17 AC 84 ms
76,540 KB
testcase_18 AC 84 ms
76,496 KB
testcase_19 AC 85 ms
76,572 KB
testcase_20 AC 89 ms
77,144 KB
testcase_21 AC 83 ms
76,448 KB
testcase_22 AC 81 ms
76,188 KB
testcase_23 AC 89 ms
76,932 KB
testcase_24 AC 90 ms
77,028 KB
testcase_25 AC 92 ms
77,260 KB
testcase_26 AC 91 ms
77,104 KB
testcase_27 AC 73 ms
71,600 KB
testcase_28 AC 74 ms
71,132 KB
testcase_29 AC 72 ms
71,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def comb(n, k, mod=10**9+7):
    num = den = 1
    for i in range(k):
        num = num * (n-i) % mod
        den = den * (i+1) % mod
    return num * pow(den, mod-2, mod) % mod

N = int(input())
S = input().rstrip()
x = y = 0
for c in S:
    if c in "AB":
        x += 1
    else:
        y += 1
mod = 998244353
print(comb(x+y, y, mod))
0