結果
| 問題 |
No.979 Longest Divisor Sequence
|
| コンテスト | |
| ユーザー |
Salmonize
|
| 提出日時 | 2020-06-04 14:54:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,267 ms / 2,000 ms |
| コード長 | 609 bytes |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 94,928 KB |
| 最終ジャッジ日時 | 2024-11-29 02:39:46 |
| 合計ジャッジ時間 | 3,465 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
import sys
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
def solve():
n = ni()
a = nl()
s = set(a)
m = max(a) + 5
g = [[1] for _ in range(m)]
for i in range(2, m):
if i in s:
for j in range(i*2, m, i):
g[j].append(i)
c = [-1]*m
c[1] = 0
for x in a:
if x == 1:
c[x] = 1
else:
c[x] = max([c[y] for y in g[x]]) + 1
print(max(c))
return
solve()
Salmonize