結果

問題 No.917 Make One With GCD
ユーザー tpynerivertpyneriver
提出日時 2019-11-07 20:12:38
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 891 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 844,424 KB
最終ジャッジ日時 2023-10-13 03:03:13
合計ジャッジ時間 4,660 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
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 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

def divi(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n//i)
    return res

from collections import Counter
Ma = 10**8 + 2
prime = [0]*Ma
for i in range(2, Ma):
    if prime[i]:
        continue
    for j in range(i, Ma, i):
        if not prime[j]:
            prime[j] = i

def pd(x):
    C = Counter()
    while x > 1:
        C[prime[x]] += 1
        x //= prime[x]
    return C


N = int(readline())
A = list(map(int, readline().split()))

divis = set()

for a in A:
    divis |= set(divi(a))

divis = list(divis)

print(divis)
res = 0
for d in divis:
    C = pd(d)
    if any(1 < c for c in C.values()):
        continue
    
    cnt = sum(1 for a in A if a % d == 0)
    
    res += (-1)**len(C) * (pow(2, cnt) - 1)

print(res)
0