結果

問題 No.1481 Rotation ABC
ユーザー chineristACchineristAC
提出日時 2021-03-08 22:03:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 81,964 KB
実行使用メモリ 69,824 KB
最終ジャッジ日時 2024-10-10 11:36:39
合計ジャッジ時間 4,354 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

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 = 2*10**5
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

N = int(input())
S = input().rstrip()
a = S.count("A")
b = S.count("B")
c = S.count("C")
if a*b*c:
    res = g1[N]*g2[a]*g2[b]*g2[c]-N
    print(res % mod)
else:
    print(1)
0