結果
| 問題 |
No.1036 Make One With GCD 2
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:37:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 685 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 82,628 KB |
| 実行使用メモリ | 189,904 KB |
| 最終ジャッジ日時 | 2025-06-12 15:38:50 |
| 合計ジャッジ時間 | 16,971 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 34 TLE * 1 -- * 6 |
ソースコード
import sys
import math
def main():
n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
result = 0
prev = {}
for a in A:
if a == 1:
count = sum(prev.values()) + 1
result += count
prev = {1: count}
continue
temp = {a: 1}
prev_list = list(prev.items())
for g, cnt in prev_list:
new_g = math.gcd(g, a)
if new_g in temp:
temp[new_g] += cnt
else:
temp[new_g] = cnt
if 1 in temp:
result += temp[1]
prev = temp
print(result)
if __name__ == "__main__":
main()
gew1fw