結果

問題 No.1036 Make One With GCD 2
コンテスト
ユーザー gew1fw
提出日時 2025-06-12 14:12:55
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 482 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 228 ms
コンパイル使用メモリ 95,464 KB
実行使用メモリ 190,208 KB
最終ジャッジ日時 2026-07-11 11:14:28
合計ジャッジ時間 19,715 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
import math
from collections import defaultdict

def main():
    n = int(sys.stdin.readline())
    a = list(map(int, sys.stdin.readline().split()))
    result = 0
    prev = defaultdict(int)
    for x in a:
        curr = defaultdict(int)
        for g, cnt in prev.items():
            new_g = math.gcd(g, x)
            curr[new_g] += cnt
        curr[x] += 1
        prev = curr
        result += prev.get(1, 0)
    print(result)

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