結果

問題 No.1927 AB-CD
ユーザー rlangevinrlangevin
提出日時 2022-12-30 04:25:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 84,612 KB
最終ジャッジ日時 2023-08-16 13:19:19
合計ジャッジ時間 5,295 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
84,024 KB
testcase_01 AC 87 ms
84,012 KB
testcase_02 AC 87 ms
84,072 KB
testcase_03 AC 86 ms
83,804 KB
testcase_04 AC 92 ms
84,560 KB
testcase_05 AC 86 ms
84,284 KB
testcase_06 AC 88 ms
84,216 KB
testcase_07 AC 87 ms
84,184 KB
testcase_08 AC 87 ms
83,748 KB
testcase_09 AC 87 ms
84,208 KB
testcase_10 AC 88 ms
84,420 KB
testcase_11 AC 87 ms
84,340 KB
testcase_12 AC 88 ms
84,072 KB
testcase_13 AC 88 ms
83,988 KB
testcase_14 AC 88 ms
83,980 KB
testcase_15 AC 88 ms
83,984 KB
testcase_16 AC 89 ms
84,316 KB
testcase_17 AC 88 ms
84,376 KB
testcase_18 AC 87 ms
84,232 KB
testcase_19 AC 90 ms
84,460 KB
testcase_20 AC 88 ms
84,416 KB
testcase_21 AC 88 ms
84,232 KB
testcase_22 AC 87 ms
84,028 KB
testcase_23 AC 88 ms
84,288 KB
testcase_24 AC 87 ms
84,416 KB
testcase_25 AC 88 ms
84,612 KB
testcase_26 AC 88 ms
84,512 KB
testcase_27 AC 86 ms
84,012 KB
testcase_28 AC 87 ms
83,788 KB
testcase_29 AC 86 ms
84,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
cnt = S.count("A") + S.count("B")

mod = 998244353

n = 505050

fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod

print(comb(N, cnt))
0