結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,352 KB
testcase_01 AC 37 ms
52,736 KB
testcase_02 AC 36 ms
52,096 KB
testcase_03 AC 35 ms
52,352 KB
testcase_04 AC 44 ms
52,608 KB
testcase_05 AC 38 ms
51,948 KB
testcase_06 AC 36 ms
51,968 KB
testcase_07 AC 36 ms
52,352 KB
testcase_08 AC 36 ms
52,352 KB
testcase_09 AC 34 ms
52,352 KB
testcase_10 AC 71 ms
64,384 KB
testcase_11 AC 67 ms
65,024 KB
testcase_12 AC 65 ms
64,768 KB
testcase_13 AC 91 ms
119,552 KB
testcase_14 AC 1,769 ms
113,220 KB
testcase_15 AC 617 ms
92,360 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:
        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