結果

問題 No.1927 AB-CD
ユーザー june19312june19312
提出日時 2022-05-10 21:06:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 77,132 KB
最終ジャッジ日時 2023-09-25 04:29:58
合計ジャッジ時間 4,644 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,272 KB
testcase_01 AC 72 ms
71,088 KB
testcase_02 AC 75 ms
71,084 KB
testcase_03 AC 74 ms
71,308 KB
testcase_04 AC 92 ms
76,716 KB
testcase_05 AC 91 ms
76,896 KB
testcase_06 AC 90 ms
77,132 KB
testcase_07 AC 89 ms
77,104 KB
testcase_08 AC 83 ms
75,788 KB
testcase_09 AC 92 ms
76,868 KB
testcase_10 AC 88 ms
76,128 KB
testcase_11 AC 89 ms
76,656 KB
testcase_12 AC 83 ms
75,792 KB
testcase_13 AC 84 ms
75,852 KB
testcase_14 AC 80 ms
75,952 KB
testcase_15 AC 82 ms
75,940 KB
testcase_16 AC 89 ms
76,660 KB
testcase_17 AC 86 ms
76,216 KB
testcase_18 AC 84 ms
75,952 KB
testcase_19 AC 88 ms
76,900 KB
testcase_20 AC 90 ms
76,768 KB
testcase_21 AC 88 ms
77,116 KB
testcase_22 AC 83 ms
76,036 KB
testcase_23 AC 92 ms
76,800 KB
testcase_24 AC 96 ms
76,932 KB
testcase_25 AC 93 ms
76,980 KB
testcase_26 AC 94 ms
76,744 KB
testcase_27 AC 72 ms
71,496 KB
testcase_28 AC 73 ms
71,276 KB
testcase_29 AC 72 ms
71,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
mod = 998_244_353

ab = 0
cd = 0

for i,v in enumerate(S):
    if v == "A" or v == "B":
        ab+=1

def nCr(n,r,modulo):
    aa = 1
    bb = 1
    for i in range(r):
        aa = aa*(n-i)%modulo
        bb = bb*(i+1)%modulo
    #逆元
    inv =  pow(bb,modulo-2,modulo)

    return aa*inv%modulo

ans = nCr(N,ab,mod)

print(ans)
0