結果

問題 No.979 Longest Divisor Sequence
ユーザー kumatan400kumatan400
提出日時 2021-09-11 03:22:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,670 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 143,892 KB
最終ジャッジ日時 2023-09-03 23:36:08
合計ジャッジ時間 5,286 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,628 KB
testcase_01 AC 72 ms
71,480 KB
testcase_02 AC 73 ms
71,264 KB
testcase_03 AC 77 ms
71,492 KB
testcase_04 AC 74 ms
71,584 KB
testcase_05 AC 73 ms
71,260 KB
testcase_06 AC 71 ms
71,396 KB
testcase_07 AC 76 ms
71,400 KB
testcase_08 AC 72 ms
71,616 KB
testcase_09 AC 73 ms
71,280 KB
testcase_10 AC 110 ms
79,336 KB
testcase_11 AC 111 ms
79,144 KB
testcase_12 AC 111 ms
79,176 KB
testcase_13 AC 130 ms
122,844 KB
testcase_14 AC 1,670 ms
143,892 KB
testcase_15 AC 765 ms
101,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

D = {}
for a in A:
    if a in D:
        continue
    i = 1
    D[a] = []
    while i * i <= a:
        if a % i == 0:
            D[a].append(i)
            j = a // i
            if i != j:
                D[a].append(j)
        i += 1


dp = [0] * (max(A)+1)
for a in A:
    if a == 1:
        dp[a] = 1
        continue
    for c in D[a]:
        if a == c:
            continue
        dp[a] = max(dp[a], dp[c] + 1)

print(max(dp))

0