結果

問題 No.443 GCD of Permutation
ユーザー ebicochinealebicochineal
提出日時 2016-11-12 00:30:21
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 808 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 184,000 KB
最終ジャッジ日時 2023-08-16 20:33:47
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
70,940 KB
testcase_01 AC 70 ms
70,944 KB
testcase_02 AC 70 ms
71,104 KB
testcase_03 AC 70 ms
70,840 KB
testcase_04 AC 105 ms
76,000 KB
testcase_05 AC 70 ms
70,668 KB
testcase_06 AC 70 ms
70,684 KB
testcase_07 AC 84 ms
76,040 KB
testcase_08 AC 70 ms
70,604 KB
testcase_09 AC 70 ms
70,664 KB
testcase_10 AC 70 ms
70,776 KB
testcase_11 AC 70 ms
70,880 KB
testcase_12 AC 72 ms
70,848 KB
testcase_13 AC 72 ms
70,720 KB
testcase_14 AC 71 ms
70,904 KB
testcase_15 RE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#! /usr/bin/env python3

def f(n):
    l = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            l += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : l += [n]
    return [1] + l

def g(a, b):
    r = []
    for i in a:
        if b % i == 0:
            r += [i]
            b //= i
    return r

gs = set([])
ga = 0
def p(s, ss):
    global ga
    if s == '':
        a = int(ss)
        gs.add(a)
        ga = a
    for i in set(s):
        p(s.replace(i, '', 1), ss+i)

def main():
    l = input()
    if len(set(l)) == 1:
        print(l)
        return
    
    s = set([])
    p(l,'')
    a = f(ga)
    for i in gs:
        a = g(a, i)
    ans = 1
    for i in a:
        ans *= i
    print(ans)

if __name__ == '__main__':
    main()
0