結果

問題 No.1927 AB-CD
ユーザー とりゐとりゐ
提出日時 2022-05-06 21:22:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 89,080 KB
最終ジャッジ日時 2023-09-20 02:05:02
合計ジャッジ時間 5,663 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
88,020 KB
testcase_01 AC 112 ms
87,684 KB
testcase_02 AC 111 ms
87,756 KB
testcase_03 AC 110 ms
87,856 KB
testcase_04 AC 122 ms
88,764 KB
testcase_05 AC 123 ms
88,776 KB
testcase_06 AC 120 ms
88,756 KB
testcase_07 AC 120 ms
88,676 KB
testcase_08 AC 116 ms
87,868 KB
testcase_09 AC 122 ms
88,800 KB
testcase_10 AC 122 ms
88,644 KB
testcase_11 AC 124 ms
89,004 KB
testcase_12 AC 118 ms
88,340 KB
testcase_13 AC 118 ms
88,692 KB
testcase_14 AC 114 ms
87,932 KB
testcase_15 AC 114 ms
87,708 KB
testcase_16 AC 121 ms
88,980 KB
testcase_17 AC 123 ms
88,700 KB
testcase_18 AC 121 ms
88,584 KB
testcase_19 AC 120 ms
88,896 KB
testcase_20 AC 122 ms
88,860 KB
testcase_21 AC 121 ms
88,852 KB
testcase_22 AC 120 ms
88,456 KB
testcase_23 AC 124 ms
88,792 KB
testcase_24 AC 126 ms
89,008 KB
testcase_25 AC 124 ms
88,956 KB
testcase_26 AC 125 ms
89,080 KB
testcase_27 AC 112 ms
87,796 KB
testcase_28 AC 113 ms
88,016 KB
testcase_29 AC 114 ms
87,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=input()
cnt=0
for i in s:
  if i=='A' or i=='B':
    cnt+=1
    

mod=998244353
#nCr mod p
M=(10**5)*5+1 
fac=[1]*M
ninv=[1]*M
finv=[1]*M
for i in range(2,M):
  fac[i]=fac[i-1]*i%mod
  ninv[i]=(-(mod//i)*ninv[mod%i])%mod
  finv[i]=finv[i-1]*ninv[i]%mod

def comb(n,k):
  if k>n:
    return 0
  return (fac[n]*finv[k]%mod)*finv[n-k]%mod

print(comb(n,cnt))
0