結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,264 KB
testcase_01 AC 35 ms
52,840 KB
testcase_02 AC 36 ms
52,124 KB
testcase_03 AC 38 ms
52,344 KB
testcase_04 AC 37 ms
52,496 KB
testcase_05 AC 38 ms
52,484 KB
testcase_06 AC 36 ms
53,240 KB
testcase_07 AC 40 ms
52,680 KB
testcase_08 AC 37 ms
53,356 KB
testcase_09 AC 36 ms
52,676 KB
testcase_10 AC 72 ms
65,864 KB
testcase_11 AC 67 ms
66,052 KB
testcase_12 AC 67 ms
65,024 KB
testcase_13 AC 95 ms
119,168 KB
testcase_14 AC 1,777 ms
113,408 KB
testcase_15 AC 619 ms
92,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int, input().split()))
ma = max(A)
dp = [0] * (ma + 1)

for a in A:
    if a == 1:
        ma = 1
    else:
        if dp[1] + 1 > dp[a]:
            ma = dp[1] + 1
        else:
            ma = dp[a]
    for i in range(2, int(a ** 0.5 + 1)):
        if a % i == 0:
            if dp[i] + 1 > ma:
                ma = dp[i] + 1
            elif dp[a // i] + 1 > ma:
                ma = dp[a // i] + 1
    dp[a] = ma
print(max(dp))
0