結果

問題 No.979 Longest Divisor Sequence
ユーザー kumatan400kumatan400
提出日時 2021-07-10 14:50:00
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 554 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 122,448 KB
最終ジャッジ日時 2023-09-14 19:28:35
合計ジャッジ時間 5,047 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,492 KB
testcase_01 AC 72 ms
71,464 KB
testcase_02 AC 68 ms
71,536 KB
testcase_03 AC 69 ms
71,748 KB
testcase_04 AC 70 ms
71,756 KB
testcase_05 AC 70 ms
71,460 KB
testcase_06 AC 70 ms
71,456 KB
testcase_07 AC 70 ms
71,740 KB
testcase_08 AC 70 ms
71,660 KB
testcase_09 AC 71 ms
71,752 KB
testcase_10 AC 107 ms
79,856 KB
testcase_11 AC 108 ms
79,268 KB
testcase_12 AC 107 ms
79,264 KB
testcase_13 AC 125 ms
122,448 KB
testcase_14 TLE -
testcase_15 AC 714 ms
93,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 約数のリストを得る
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))
0