結果

問題 No.443 GCD of Permutation
ユーザー ebicochinealebicochineal
提出日時 2016-11-11 23:40:32
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 621 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 86,592 KB
実行使用メモリ 85,588 KB
最終ジャッジ日時 2023-08-16 19:52:23
合計ジャッジ時間 4,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
79,812 KB
testcase_01 AC 72 ms
71,180 KB
testcase_02 AC 74 ms
71,372 KB
testcase_03 AC 76 ms
75,196 KB
testcase_04 AC 106 ms
77,380 KB
testcase_05 AC 73 ms
71,324 KB
testcase_06 AC 72 ms
71,076 KB
testcase_07 AC 84 ms
75,956 KB
testcase_08 AC 72 ms
71,420 KB
testcase_09 AC 77 ms
75,052 KB
testcase_10 AC 72 ms
71,252 KB
testcase_11 AC 76 ms
75,284 KB
testcase_12 AC 71 ms
71,320 KB
testcase_13 AC 71 ms
71,372 KB
testcase_14 RE -
testcase_15 TLE -
testcase_16 -- -
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

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