結果

問題 No.1927 AB-CD
ユーザー 👑 tamatotamato
提出日時 2022-05-06 21:29:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 83,704 KB
最終ジャッジ日時 2023-09-20 02:22:07
合計ジャッジ時間 4,672 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
83,112 KB
testcase_01 AC 91 ms
82,976 KB
testcase_02 AC 93 ms
82,924 KB
testcase_03 AC 92 ms
82,980 KB
testcase_04 AC 94 ms
83,436 KB
testcase_05 AC 94 ms
83,368 KB
testcase_06 AC 94 ms
83,332 KB
testcase_07 AC 95 ms
83,472 KB
testcase_08 AC 94 ms
82,988 KB
testcase_09 AC 94 ms
83,416 KB
testcase_10 AC 94 ms
83,652 KB
testcase_11 AC 93 ms
83,332 KB
testcase_12 AC 93 ms
83,008 KB
testcase_13 AC 96 ms
83,076 KB
testcase_14 AC 92 ms
82,972 KB
testcase_15 AC 93 ms
82,948 KB
testcase_16 AC 96 ms
83,592 KB
testcase_17 AC 94 ms
83,320 KB
testcase_18 AC 95 ms
83,296 KB
testcase_19 AC 95 ms
83,352 KB
testcase_20 AC 95 ms
83,416 KB
testcase_21 AC 94 ms
83,276 KB
testcase_22 AC 94 ms
83,076 KB
testcase_23 AC 95 ms
83,516 KB
testcase_24 AC 95 ms
83,580 KB
testcase_25 AC 96 ms
83,632 KB
testcase_26 AC 95 ms
83,704 KB
testcase_27 AC 92 ms
83,004 KB
testcase_28 AC 94 ms
83,132 KB
testcase_29 AC 93 ms
83,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    nmax = 3 * 10 ** 5 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N = int(input())
    S = input().rstrip('\n')

    M = S.count("A") + S.count("B")
    print(comb(N, M))


if __name__ == '__main__':
    main()
0