結果

問題 No.171 スワップ文字列(Med)
ユーザー tnodinotnodino
提出日時 2022-06-25 17:14:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 669 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 76,096 KB
最終ジャッジ日時 2023-08-09 09:47:31
合計ジャッジ時間 3,393 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,264 KB
testcase_01 AC 73 ms
71,172 KB
testcase_02 AC 84 ms
76,096 KB
testcase_03 AC 75 ms
75,424 KB
testcase_04 AC 76 ms
75,836 KB
testcase_05 AC 80 ms
75,424 KB
testcase_06 AC 87 ms
76,028 KB
testcase_07 AC 90 ms
75,956 KB
testcase_08 AC 91 ms
76,008 KB
testcase_09 AC 91 ms
76,084 KB
testcase_10 AC 72 ms
71,116 KB
testcase_11 AC 70 ms
71,296 KB
testcase_12 AC 72 ms
71,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 573
class PascalsTriangle:
    def __init__(self, N, mod):
        self.mod = mod
        self.tri = [[0] * (N+1) for _ in range(N+1)]
        for i in range(N+1):
            for j in range(i+1):
                if j == 0 or j == i:
                    self.tri[i][j] = 1
                else:
                    self.tri[i][j] = (self.tri[i-1][j] + self.tri[i-1][j-1]) % self.mod

    def comb(self, n, r):
        if n < r or r < 0:
            return 0
        return self.tri[n][r]

S = input()
N = len(S)
T = PascalsTriangle(N, mod)
ans = 1
for i in range(26):
    c = S.count(chr(i+65))
    ans *= T.comb(N, c)
    ans %= mod
    N -= c
print((ans-1)%mod)
0