結果

問題 No.443 GCD of Permutation
ユーザー ebicochineal
提出日時 2016-11-11 23:39:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 621 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 26,496 KB
最終ジャッジ日時 2024-11-25 09:43:22
合計ジャッジ時間 17,681 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 RE * 10 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#! /usr/bin/env python3

import itertools

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 i in b:
            b.remove(i)
            r += [i]
    return r
    

def to_n(l):
    return int(''.join(l))

l = input()
s = set([])
for i in itertools.permutations(l, len(l)):
    t = to_n(i)
    s.add(t)
a = f(sorted(s)[0])
for i in s:
    a = g(a, f(i))
ans = 1
for i in a:
    ans *= i
print(ans)
0