結果

問題 No.979 Longest Divisor Sequence
ユーザー stngstng
提出日時 2022-08-17 09:54:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,885 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 109,948 KB
最終ジャッジ日時 2024-04-15 01:34:49
合計ジャッジ時間 4,502 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,560 KB
testcase_01 AC 41 ms
53,508 KB
testcase_02 AC 42 ms
52,776 KB
testcase_03 AC 42 ms
52,536 KB
testcase_04 AC 41 ms
52,260 KB
testcase_05 AC 40 ms
53,448 KB
testcase_06 AC 40 ms
53,212 KB
testcase_07 AC 40 ms
52,500 KB
testcase_08 AC 39 ms
52,616 KB
testcase_09 AC 40 ms
53,132 KB
testcase_10 AC 83 ms
73,292 KB
testcase_11 AC 79 ms
71,852 KB
testcase_12 AC 82 ms
72,884 KB
testcase_13 AC 139 ms
102,036 KB
testcase_14 AC 1,885 ms
109,948 KB
testcase_15 AC 670 ms
87,460 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)

    divisors.sort()
    return divisors[:-1]

n = int(input())
a = [int(i) for i in input().split()]

dp = [0]*(max(a)+1)

for i in range(n):
    div = make_divisors(a[i])
    tmp = 0
    for j in range(len(div)):
        #print(div[j],j)
        tmp = max(tmp,dp[div[j]])
    dp[a[i]] = max(dp[a[i]],tmp+1)

print(max(dp))
0