結果

問題 No.979 Longest Divisor Sequence
ユーザー kumatan400kumatan400
提出日時 2021-07-10 14:49:07
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 572 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 86,656 KB
実行使用メモリ 154,684 KB
最終ジャッジ日時 2023-09-14 19:28:29
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,760 KB
testcase_01 AC 70 ms
71,792 KB
testcase_02 AC 70 ms
71,788 KB
testcase_03 AC 71 ms
71,576 KB
testcase_04 AC 71 ms
71,396 KB
testcase_05 AC 72 ms
71,680 KB
testcase_06 AC 71 ms
71,580 KB
testcase_07 AC 69 ms
71,788 KB
testcase_08 AC 70 ms
71,400 KB
testcase_09 AC 71 ms
71,628 KB
testcase_10 AC 110 ms
79,304 KB
testcase_11 AC 111 ms
79,592 KB
testcase_12 AC 108 ms
79,728 KB
testcase_13 AC 215 ms
124,440 KB
testcase_14 TLE -
testcase_15 AC 753 ms
99,092 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()))
Ay = [make_divisors(a) for a in A]

dp = [0] * (max(A)+1)
for a, Y in zip(A, Ay):
    if a == 1:
        dp[a] = 1
    else:
        t = 0
        for y in Y:
            if y == a:
                continue
            dp[a] = max(dp[a], dp[y] + 1)

print(max(dp))
0