結果

問題 No.917 Make One With GCD
ユーザー tamato
提出日時 2020-05-04 23:25:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,768 KB
実行使用メモリ 64,700 KB
最終ジャッジ日時 2024-06-24 11:16:00
合計ジャッジ時間 2,836 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    def gcd(a, b):
        while a%b:
            a, b = b, a%b
        return b

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

    G = defaultdict(int)
    for a in A:
        tmp = []
        for v in G:
            tmp.append((gcd(v, a), G[v]))
        for x, y in tmp:
            G[x] += y
        G[a] += 1
    print(G[1])


if __name__ == '__main__':
    main()
0