結果

問題 No.979 Longest Divisor Sequence
ユーザー stngstng
提出日時 2022-08-17 10:08:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 110,124 KB
最終ジャッジ日時 2024-04-15 01:44:34
合計ジャッジ時間 4,103 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,648 KB
testcase_01 AC 37 ms
53,540 KB
testcase_02 AC 39 ms
52,940 KB
testcase_03 AC 37 ms
52,880 KB
testcase_04 WA -
testcase_05 AC 38 ms
52,864 KB
testcase_06 AC 39 ms
52,524 KB
testcase_07 AC 38 ms
53,420 KB
testcase_08 AC 38 ms
52,996 KB
testcase_09 AC 37 ms
53,388 KB
testcase_10 AC 77 ms
71,852 KB
testcase_11 AC 73 ms
69,872 KB
testcase_12 AC 75 ms
71,672 KB
testcase_13 WA -
testcase_14 AC 1,778 ms
110,124 KB
testcase_15 AC 631 ms
87,308 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 == 1:
                continue
            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