結果

問題 No.917 Make One With GCD
ユーザー qib
提出日時 2022-12-09 17:23:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 300 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 63,232 KB
最終ジャッジ日時 2024-10-14 18:46:41
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import math

n = int(input())
a = list(map(int, input().split()))

dp = defaultdict(int)
dp[a[0]] = 1
for i in range(1, n):
  ndp = defaultdict(int)
  ndp[a[i]] += 1
  for k, v in dp.items():
    ndp[k] += v
    ndp[math.gcd(k, a[i])] += v
  dp = ndp

print(dp[1])
0