結果

問題 No.917 Make One With GCD
ユーザー rlangevin
提出日時 2023-01-31 23:29:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 283 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 63,172 KB
最終ジャッジ日時 2024-06-30 23:45:19
合計ジャッジ時間 3,110 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import *

N = int(input())
A = list(map(int, input().split()))
pre = defaultdict(int)
pre[0] = 1
for a in A:
    dp = defaultdict(int)
    for k, v in pre.items():
        dp[gcd(k, a)] += v
        dp[k] += v
    dp, pre = pre, dp
print(pre[1])
0