結果

問題 No.171 スワップ文字列(Med)
ユーザー rlangevinrlangevin
提出日時 2023-08-29 12:07:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 759 bytes
コンパイル時間 1,218 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 78,492 KB
最終ジャッジ日時 2023-08-29 12:07:05
合計ジャッジ時間 3,248 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,780 KB
testcase_01 AC 122 ms
72,252 KB
testcase_02 AC 125 ms
78,492 KB
testcase_03 AC 92 ms
71,768 KB
testcase_04 AC 96 ms
72,012 KB
testcase_05 AC 106 ms
77,344 KB
testcase_06 AC 120 ms
78,160 KB
testcase_07 AC 122 ms
78,464 KB
testcase_08 AC 124 ms
78,032 KB
testcase_09 AC 126 ms
78,052 KB
testcase_10 AC 92 ms
72,020 KB
testcase_11 AC 93 ms
72,148 KB
testcase_12 AC 91 ms
72,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
 
    if temp != 1:
        arr.append([temp, 1])

    return arr

S = [ord(s) - ord("A") for s in input()]
N = len(S)
C = Counter(S)
M = 1005
L = [0] * M
for i in range(N, 1, -1):
    for k, v in factorization(i):
        L[k] += v

for _, v1 in C.items():
    for i in range(v1, 1, -1):
        for k, v in factorization(i):
            L[k] -= v

mod = 573
ans = 1
for i in range(2, M):
    for j in range(L[i]):
        ans *= i
        ans %= mod

print((ans-1)%mod)
0