結果
| 問題 |
No.1036 Make One With GCD 2
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:10:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 482 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 181,728 KB |
| 最終ジャッジ日時 | 2025-06-12 19:10:33 |
| 合計ジャッジ時間 | 17,977 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / 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()))
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()
gew1fw