結果
問題 |
No.1036 Make One With GCD 2
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:21:55 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 382 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 81,880 KB |
実行使用メモリ | 189,704 KB |
最終ジャッジ日時 | 2025-06-12 21:24:29 |
合計ジャッジ時間 | 17,513 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 34 TLE * 1 -- * 6 |
ソースコード
import math from collections import defaultdict n = int(input()) a = list(map(int, input().split())) total = 0 prev_gcds = defaultdict(int) for num in a: curr_gcds = defaultdict(int) curr_gcds[num] = 1 for g in prev_gcds: new_g = math.gcd(g, num) curr_gcds[new_g] += prev_gcds[g] total += curr_gcds.get(1, 0) prev_gcds = curr_gcds print(total)