結果

問題 No.1036 Make One With GCD 2
ユーザー ああいい
提出日時 2022-03-31 09:37:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 410 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 382,096 KB
最終ジャッジ日時 2024-11-16 11:54:07
合計ジャッジ時間 27,322 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

def gcd(a,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)
count = 0
d[0] = 1
for a in A:
    e = defaultdict(int)
    for k in d:
        g = gcd(k,a)
        e[g] += d[k]
    count += e[1]
    e[0] += 1
    d = e
print(count)
    
0