結果

問題 No.979 Longest Divisor Sequence
ユーザー kumatan400kumatan400
提出日時 2021-07-10 14:46:12
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 582 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 86,712 KB
実行使用メモリ 154,496 KB
最終ジャッジ日時 2023-09-14 19:27:56
合計ジャッジ時間 6,293 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,628 KB
testcase_01 AC 71 ms
71,692 KB
testcase_02 AC 72 ms
71,748 KB
testcase_03 AC 72 ms
71,636 KB
testcase_04 AC 71 ms
71,588 KB
testcase_05 AC 72 ms
71,456 KB
testcase_06 AC 73 ms
71,604 KB
testcase_07 AC 71 ms
71,844 KB
testcase_08 AC 71 ms
71,788 KB
testcase_09 AC 72 ms
71,604 KB
testcase_10 AC 121 ms
79,472 KB
testcase_11 AC 111 ms
79,528 KB
testcase_12 AC 112 ms
79,380 KB
testcase_13 AC 223 ms
124,628 KB
testcase_14 TLE -
testcase_15 AC 770 ms
99,152 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
            t = max(t, dp[y] + 1)
        dp[a] = t

print(max(dp))
0