結果
問題 | No.979 Longest Divisor Sequence |
ユーザー |
👑 |
提出日時 | 2022-03-24 17:03:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,696 ms / 2,000 ms |
コード長 | 347 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 82,472 KB |
実行使用メモリ | 119,772 KB |
最終ジャッジ日時 | 2024-10-13 01:07:28 |
合計ジャッジ時間 | 3,706 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
n = int(input()) A = list(map(int, input().split())) ma = max(A) dp = [0] * (ma + 1) for a in A: if a == 1: dp[a] = 1 else: dp[a] = max(dp[a], dp[1] + 1) for i in range(2, int(a ** 0.5 + 1)): if a % i == 0: dp[a] = max(dp[a], dp[i] + 1) dp[a] = max(dp[a], dp[a // i] + 1) print(max(dp))