結果

問題 No.979 Longest Divisor Sequence
ユーザー 👑 rin204rin204
提出日時 2022-03-24 17:03:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,760 ms / 2,000 ms
コード長 347 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 119,732 KB
最終ジャッジ日時 2024-04-21 02:39:08
合計ジャッジ時間 3,876 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,928 KB
testcase_01 AC 34 ms
52,252 KB
testcase_02 AC 36 ms
52,472 KB
testcase_03 AC 36 ms
52,692 KB
testcase_04 AC 36 ms
52,200 KB
testcase_05 AC 36 ms
52,652 KB
testcase_06 AC 37 ms
53,452 KB
testcase_07 AC 35 ms
52,336 KB
testcase_08 AC 37 ms
52,408 KB
testcase_09 AC 36 ms
54,000 KB
testcase_10 AC 72 ms
64,948 KB
testcase_11 AC 65 ms
65,560 KB
testcase_12 AC 66 ms
66,268 KB
testcase_13 AC 94 ms
119,732 KB
testcase_14 AC 1,760 ms
113,332 KB
testcase_15 AC 621 ms
92,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0