結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
|
| 提出日時 | 2021-07-10 14:50:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,890 ms / 2,000 ms |
| コード長 | 554 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 82,196 KB |
| 実行使用メモリ | 118,528 KB |
| 最終ジャッジ日時 | 2024-07-02 02:27:27 |
| 合計ジャッジ時間 | 4,080 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()))
dp = [0] * (max(A)+1)
for a in A:
if a == 1:
dp[a] = 1
else:
Y = make_divisors(a)
t = 0
for y in Y:
if y == a:
continue
dp[a] = max(dp[a], dp[y] + 1)
print(max(dp))