結果

問題 No.1927 AB-CD
ユーザー ikomaikoma
提出日時 2022-05-06 21:47:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 77,088 KB
最終ジャッジ日時 2023-09-20 02:37:40
合計ジャッジ時間 4,597 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,444 KB
testcase_01 AC 72 ms
71,272 KB
testcase_02 AC 70 ms
71,472 KB
testcase_03 AC 70 ms
71,412 KB
testcase_04 AC 88 ms
76,872 KB
testcase_05 AC 86 ms
76,848 KB
testcase_06 AC 85 ms
76,592 KB
testcase_07 AC 84 ms
76,524 KB
testcase_08 AC 80 ms
76,016 KB
testcase_09 AC 90 ms
76,848 KB
testcase_10 AC 84 ms
76,296 KB
testcase_11 AC 86 ms
76,904 KB
testcase_12 AC 80 ms
76,080 KB
testcase_13 AC 80 ms
76,028 KB
testcase_14 AC 76 ms
75,968 KB
testcase_15 AC 78 ms
76,024 KB
testcase_16 AC 87 ms
76,720 KB
testcase_17 AC 83 ms
76,376 KB
testcase_18 AC 83 ms
76,492 KB
testcase_19 AC 87 ms
76,372 KB
testcase_20 AC 91 ms
76,672 KB
testcase_21 AC 84 ms
76,268 KB
testcase_22 AC 78 ms
75,948 KB
testcase_23 AC 88 ms
76,936 KB
testcase_24 AC 92 ms
77,076 KB
testcase_25 AC 92 ms
77,068 KB
testcase_26 AC 91 ms
77,088 KB
testcase_27 AC 71 ms
71,268 KB
testcase_28 AC 71 ms
71,256 KB
testcase_29 AC 73 ms
71,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input().strip()
n_ab=0
for s in S:
    if s in "AB":
        n_ab+=1
n_cd = N-n_ab
def combo(n, k, mod=998244353):
    def fact(n,k=0):
        a=1
        for i in range(k+1,n+1):
            a=a * i % mod
        return a
    k=min(k,n-k)
    a=fact(n, n-k) # (n-k)!
    b=fact(k) # k!
    return (a * pow(b, mod-2, mod)) % mod
print(combo(N, n_ab))
0