結果
問題 |
No.1036 Make One With GCD 2
|
ユーザー |
![]() |
提出日時 | 2025-04-16 00:35:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 624 bytes |
コンパイル時間 | 345 ms |
コンパイル使用メモリ | 82,492 KB |
実行使用メモリ | 191,396 KB |
最終ジャッジ日時 | 2025-04-16 00:36:50 |
合計ジャッジ時間 | 17,266 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 34 TLE * 1 -- * 6 |
ソースコード
import sys import math from collections import defaultdict def main(): n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) total = 0 prev = dict() for num in a: curr = defaultdict(int) # Process previous GCDs for g in prev: new_g = math.gcd(g, num) curr[new_g] += prev[g] # Add the current number as a single-element subarray curr[num] += 1 # Update total total += curr.get(1, 0) # Update prev for next iteration prev = curr print(total) if __name__ == "__main__": main()