結果

問題 No.443 GCD of Permutation
ユーザー ebicochinealebicochineal
提出日時 2016-11-11 23:49:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 670 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 12,900 KB
最終ジャッジ日時 2023-08-16 20:00:41
合計ジャッジ時間 3,541 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,500 KB
testcase_01 AC 16 ms
8,236 KB
testcase_02 AC 15 ms
8,240 KB
testcase_03 AC 16 ms
8,152 KB
testcase_04 AC 33 ms
8,320 KB
testcase_05 AC 15 ms
8,132 KB
testcase_06 AC 15 ms
8,120 KB
testcase_07 AC 16 ms
8,180 KB
testcase_08 AC 16 ms
8,240 KB
testcase_09 AC 16 ms
8,120 KB
testcase_10 AC 15 ms
8,236 KB
testcase_11 AC 15 ms
8,144 KB
testcase_12 AC 15 ms
8,268 KB
testcase_13 AC 15 ms
8,156 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 b % i == 0:
            r += [i]
            b //= i
    return r
    

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

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