結果

問題 No.917 Make One With GCD
コンテスト
ユーザー n_bitand_n_per_3
提出日時 2026-07-20 18:45:50
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 236 ms
コンパイル使用メモリ 96,364 KB
実行使用メモリ 89,856 KB
最終ジャッジ日時 2026-07-20 18:45:58
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other TLE * 1 -- * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import isqrt

def divsor(x):
  arr = []
  for i in range(1,isqrt(x)+1):
    if x % i == 0:
      arr.append(i)
      if i*i != x:
        arr.append(x//i)
  return arr
    
N = int(input())
A = list(map(int,input().split()))
M = max(A)

S = set()
for a in A:
  for d in divsor(a):
    S.add(d)

S_arr = list(S)
S_arr.sort(reverse=True)
#print(S)

dp = {}

for d in S_arr:
  cnt = 0
  for a in A:
    if a % d == 0:
      cnt += 1
  dp[d] = 2**cnt-1

#print(dp)

for d in S_arr:
  for i in range(2*d,M+1,d):
    if i in S:
      dp[d] -= dp[i]

#print(dp)
print(dp[1])





0