結果

問題 No.917 Make One With GCD
ユーザー 👑 H20H20
提出日時 2021-12-27 17:19:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 81,612 KB
実行使用メモリ 64,752 KB
最終ジャッジ日時 2023-10-26 03:03:29
合計ジャッジ時間 3,822 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
64,752 KB
testcase_01 AC 39 ms
55,692 KB
testcase_02 AC 39 ms
55,692 KB
testcase_03 AC 39 ms
55,692 KB
testcase_04 AC 39 ms
55,692 KB
testcase_05 AC 38 ms
55,692 KB
testcase_06 AC 39 ms
55,756 KB
testcase_07 AC 39 ms
55,756 KB
testcase_08 AC 38 ms
55,756 KB
testcase_09 AC 50 ms
64,656 KB
testcase_10 AC 49 ms
64,600 KB
testcase_11 AC 48 ms
64,580 KB
testcase_12 AC 50 ms
64,600 KB
testcase_13 AC 49 ms
64,596 KB
testcase_14 AC 47 ms
64,580 KB
testcase_15 AC 49 ms
64,580 KB
testcase_16 AC 48 ms
62,532 KB
testcase_17 AC 41 ms
59,572 KB
testcase_18 AC 42 ms
59,572 KB
testcase_19 AC 38 ms
55,756 KB
testcase_20 AC 43 ms
59,572 KB
testcase_21 AC 42 ms
59,572 KB
testcase_22 AC 40 ms
59,572 KB
testcase_23 AC 42 ms
61,620 KB
testcase_24 AC 41 ms
59,572 KB
testcase_25 AC 43 ms
61,620 KB
testcase_26 AC 40 ms
59,572 KB
testcase_27 AC 38 ms
55,756 KB
testcase_28 AC 38 ms
55,692 KB
testcase_29 AC 38 ms
55,756 KB
testcase_30 AC 39 ms
55,756 KB
testcase_31 AC 38 ms
55,756 KB
testcase_32 AC 38 ms
55,756 KB
testcase_33 AC 38 ms
55,756 KB
testcase_34 AC 38 ms
55,756 KB
testcase_35 AC 39 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import math

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a = list(set(a))
    m=1
    for i in a:
        m*=i
    return m

N = int(input())
A = list(map(int,input().split()))
d = collections.defaultdict(int)
for a in A:
    nd = collections.defaultdict(int)
    a = prime_factorize(a)
    for k,v in d.items():
        p = math.gcd(a,k)
        if p>1:
            nd[p]+=d[k]

    for k,v in d.items():
        nd[k]+=v    
    if a>1:
        nd[a]+=1
    d = nd
s = 0
for k,v in d.items():
    s+=v
print(2**N-1-s)

0