結果

問題 No.917 Make One With GCD
ユーザー ああいいああいい
提出日時 2022-02-23 16:13:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 81,644 KB
実行使用メモリ 64,512 KB
最終ジャッジ日時 2024-07-01 15:49:39
合計ジャッジ時間 2,963 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
def gcd(a,b):
    if a == 0:return b
    if b == 0:return a
    while True:
        r = a % b
        a = b
        b = r
        if r == 0:return a
from collections import defaultdict
d = defaultdict(int)
d[0] = 1
for i in range(N):
    e = defaultdict(int)
    for v in d:
        e[v] += d[v]
        e[gcd(v,A[i])] += d[v]
    d = e
print(d[1])
0