結果

問題 No.443 GCD of Permutation
ユーザー ebicochinealebicochineal
提出日時 2016-11-11 23:39:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 621 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 12,836 KB
最終ジャッジ日時 2023-08-16 19:52:01
合計ジャッジ時間 3,489 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,584 KB
testcase_01 AC 16 ms
8,196 KB
testcase_02 AC 15 ms
8,132 KB
testcase_03 AC 16 ms
8,276 KB
testcase_04 AC 83 ms
8,220 KB
testcase_05 AC 15 ms
8,136 KB
testcase_06 AC 16 ms
8,136 KB
testcase_07 AC 22 ms
8,244 KB
testcase_08 AC 16 ms
8,204 KB
testcase_09 AC 16 ms
8,148 KB
testcase_10 AC 16 ms
8,196 KB
testcase_11 AC 17 ms
8,244 KB
testcase_12 AC 16 ms
8,240 KB
testcase_13 AC 16 ms
8,196 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