結果
| 問題 | No.917 Make One With GCD |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-20 18:45:50 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 583 bytes |
| 記録 | |
| コンパイル時間 | 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 |
ソースコード
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])