結果

問題 No.1927 AB-CD
ユーザー Omura ShunsukeOmura Shunsuke
提出日時 2022-05-11 23:00:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 86,728 KB
実行使用メモリ 164,840 KB
最終ジャッジ日時 2023-09-26 14:38:28
合計ジャッジ時間 9,313 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
163,956 KB
testcase_01 AC 157 ms
163,884 KB
testcase_02 AC 167 ms
164,060 KB
testcase_03 AC 156 ms
164,032 KB
testcase_04 AC 162 ms
164,440 KB
testcase_05 AC 163 ms
164,560 KB
testcase_06 AC 165 ms
164,708 KB
testcase_07 AC 166 ms
164,356 KB
testcase_08 AC 171 ms
164,080 KB
testcase_09 AC 173 ms
164,396 KB
testcase_10 AC 165 ms
164,320 KB
testcase_11 AC 169 ms
164,504 KB
testcase_12 AC 167 ms
163,948 KB
testcase_13 AC 171 ms
163,956 KB
testcase_14 AC 166 ms
164,068 KB
testcase_15 AC 159 ms
163,732 KB
testcase_16 AC 170 ms
164,536 KB
testcase_17 AC 167 ms
164,376 KB
testcase_18 AC 165 ms
164,444 KB
testcase_19 AC 162 ms
164,424 KB
testcase_20 AC 163 ms
164,372 KB
testcase_21 AC 160 ms
164,480 KB
testcase_22 AC 159 ms
163,732 KB
testcase_23 AC 169 ms
164,840 KB
testcase_24 AC 168 ms
164,444 KB
testcase_25 AC 172 ms
164,456 KB
testcase_26 AC 167 ms
164,656 KB
testcase_27 AC 160 ms
164,068 KB
testcase_28 AC 167 ms
164,100 KB
testcase_29 AC 161 ms
163,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = (10**5)*4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
N = int(input())
cnt = 0
S = input()
for i in range(N):
    if S[i] == "A" or S[i] == "B":
        cnt += 1
print(cmb(N,cnt,mod))
0