結果

問題 No.443 GCD of Permutation
ユーザー ebicochinealebicochineal
提出日時 2016-11-12 00:29:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 178,152 KB
最終ジャッジ日時 2023-08-16 20:33:34
合計ジャッジ時間 5,033 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,300 KB
testcase_01 WA -
testcase_02 AC 64 ms
71,452 KB
testcase_03 AC 68 ms
71,548 KB
testcase_04 AC 91 ms
76,932 KB
testcase_05 AC 71 ms
71,180 KB
testcase_06 AC 64 ms
71,444 KB
testcase_07 AC 75 ms
76,640 KB
testcase_08 AC 65 ms
71,504 KB
testcase_09 AC 68 ms
71,584 KB
testcase_10 AC 67 ms
71,388 KB
testcase_11 AC 64 ms
71,328 KB
testcase_12 AC 64 ms
71,328 KB
testcase_13 AC 65 ms
71,308 KB
testcase_14 WA -
testcase_15 RE -
testcase_16 TLE -
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 #

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()
    if len(set(l)) == 1:
        print(1)
        return
    
    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