結果

問題 No.979 Longest Divisor Sequence
ユーザー kumatan400kumatan400
提出日時 2021-07-07 17:46:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,794 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 122,484 KB
最終ジャッジ日時 2023-09-14 04:39:07
合計ジャッジ時間 5,586 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,624 KB
testcase_01 AC 78 ms
71,692 KB
testcase_02 AC 61 ms
71,704 KB
testcase_03 AC 60 ms
71,704 KB
testcase_04 AC 60 ms
71,388 KB
testcase_05 AC 59 ms
71,736 KB
testcase_06 AC 59 ms
71,608 KB
testcase_07 AC 60 ms
71,284 KB
testcase_08 AC 60 ms
71,504 KB
testcase_09 AC 59 ms
71,508 KB
testcase_10 AC 93 ms
79,528 KB
testcase_11 AC 93 ms
79,436 KB
testcase_12 AC 97 ms
79,588 KB
testcase_13 AC 115 ms
122,484 KB
testcase_14 AC 1,794 ms
118,596 KB
testcase_15 AC 637 ms
93,828 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
        continue

    D = make_divisors(a)


    for d in D:
        if d == a:
            continue

        dp[a] = max(dp[a],  dp[d] + 1)

print(max(dp))
0