結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2016-07-30 13:05:40 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 32,376 KB |
最終ジャッジ日時 | 2024-11-06 21:14:58 |
合計ジャッジ時間 | 7,438 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 1 -- * 13 |
ソースコード
import math def get_divisors(n): if n == 1: return [] ret = [] for i in range(1, int(math.sqrt(n)) + 1): if n % i == 0: ret.append(i) if i != 1 and i != n // i: ret.append(n // i) return ret input() xi = sorted(map(int, input().split())) dp = [-99999 for _ in range(10**6 + 1)] max_len = 0 for x in xi: di = get_divisors(x) if di == [1] and x != 1 and xi[0] == 1: dp[x] = 2 elif di == [1] and x != 1: dp[x] = 1 elif x == 1: dp[x] = 1 else: dp[x] = max([dp[d] for d in di]) + 1 max_len = max(max_len, dp[x]) print(max_len)