結果

問題 No.979 Longest Divisor Sequence
ユーザー brthyyjpbrthyyjp
提出日時 2021-02-08 02:33:02
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 499 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 122,440 KB
最終ジャッジ日時 2023-09-18 05:11:26
合計ジャッジ時間 5,546 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,764 KB
testcase_01 AC 70 ms
71,844 KB
testcase_02 AC 69 ms
71,768 KB
testcase_03 AC 68 ms
71,648 KB
testcase_04 AC 75 ms
71,484 KB
testcase_05 AC 72 ms
71,412 KB
testcase_06 AC 69 ms
71,820 KB
testcase_07 AC 69 ms
71,456 KB
testcase_08 AC 71 ms
71,680 KB
testcase_09 AC 70 ms
71,592 KB
testcase_10 AC 112 ms
79,336 KB
testcase_11 AC 106 ms
79,756 KB
testcase_12 AC 108 ms
79,136 KB
testcase_13 AC 122 ms
122,440 KB
testcase_14 TLE -
testcase_15 AC 729 ms
93,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

dp = [0]*(max(A)+1)
for a in A:
    if a == 1:
        dp[1] = 1
        continue
    d = make_divisors(a)
    for i in d:
        if i == a:
            continue
        dp[a] = max(dp[i]+1, dp[a])
#print(dp)
print(max(dp))
0