結果

問題 No.171 スワップ文字列(Med)
コンテスト
ユーザー nebukuro09
提出日時 2016-09-21 15:21:02
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 91 ms / 1,000 ms
+ 607µs
コード長 460 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 81,088 KB
実行使用メモリ 83,424 KB
最終ジャッジ日時 2026-09-25 08:01:18
合計ジャッジ時間 2,255 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import Counter
import operator
MOD = 573

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

c = Counter(raw_input()).values()
bunbo = range(sum(c), 0, -1)
for n in c:
    for m in xrange(1, n+1):
        p = 0
        while m > 1:
            cd = gcd(m, bunbo[p])
            if cd > 1:
                bunbo[p] /= cd
                m /= cd
            p += 1

ans = 1
for b in bunbo:
    ans = ans * b % MOD
print (ans-1)%MOD
0