結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
|
提出日時 | 2021-07-10 14:49:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,886 ms / 2,000 ms |
コード長 | 572 bytes |
コンパイル時間 | 181 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 149,404 KB |
最終ジャッジ日時 | 2024-07-02 02:27:22 |
合計ジャッジ時間 | 4,229 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
# 約数のリストを得る def make_divisors(n): divisors = [] for i in range(1, int(n ** 0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors N = int(input()) A = list(map(int, input().split())) Ay = [make_divisors(a) for a in A] dp = [0] * (max(A)+1) for a, Y in zip(A, Ay): if a == 1: dp[a] = 1 else: t = 0 for y in Y: if y == a: continue dp[a] = max(dp[a], dp[y] + 1) print(max(dp))