結果
| 問題 | No.979 Longest Divisor Sequence |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-27 20:50:52 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 667 ms / 2,000 ms |
| コード長 | 517 bytes |
| 記録 | |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 85,160 KB |
| 実行使用メモリ | 131,148 KB |
| 最終ジャッジ日時 | 2026-04-19 02:09:54 |
| 合計ジャッジ時間 | 2,713 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
def divisors(n):
i = 1
table = set()
while i * i <= n:
if not n % i:
table.add(i)
table.add(n//i)
i += 1
table = sorted(list(table)) # 速度が欲しい時は消す
return table
import sys
input = sys.stdin.readline
N=int(input())
A=list(map(int, input().split()))
dp=[-1]*(max(A) + 1)
dp[1]=0
for a in A:
tmp=0
for n in divisors(a):
if n==a: continue
if dp[n]==-1: continue
tmp=max(tmp,dp[n])
dp[a]=tmp+1
print(max(dp))