結果

問題 No.171 スワップ文字列(Med)
ユーザー tnodinotnodino
提出日時 2022-06-25 17:14:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 1,000 ms
コード長 669 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 82,028 KB
実行使用メモリ 69,456 KB
最終ジャッジ日時 2024-04-27 00:23:42
合計ジャッジ時間 1,887 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,484 KB
testcase_01 AC 37 ms
52,340 KB
testcase_02 AC 49 ms
62,932 KB
testcase_03 AC 42 ms
58,756 KB
testcase_04 AC 41 ms
59,172 KB
testcase_05 AC 48 ms
61,524 KB
testcase_06 AC 54 ms
65,960 KB
testcase_07 AC 56 ms
67,428 KB
testcase_08 AC 59 ms
69,456 KB
testcase_09 AC 60 ms
68,592 KB
testcase_10 AC 38 ms
53,132 KB
testcase_11 AC 38 ms
52,268 KB
testcase_12 AC 37 ms
52,488 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