結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,328 KB
testcase_01 AC 13 ms
8,204 KB
testcase_02 AC 13 ms
8,248 KB
testcase_03 AC 14 ms
8,320 KB
testcase_04 AC 14 ms
8,408 KB
testcase_05 AC 12 ms
8,156 KB
testcase_06 AC 13 ms
8,204 KB
testcase_07 AC 14 ms
8,348 KB
testcase_08 AC 13 ms
8,244 KB
testcase_09 AC 13 ms
8,292 KB
testcase_10 AC 13 ms
8,164 KB
testcase_11 AC 13 ms
8,300 KB
testcase_12 AC 13 ms
8,156 KB
testcase_13 AC 13 ms
8,236 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 TLE -
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

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()
    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