結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,196 KB
testcase_01 AC 38 ms
52,208 KB
testcase_02 AC 39 ms
52,904 KB
testcase_03 WA -
testcase_04 AC 38 ms
53,420 KB
testcase_05 AC 38 ms
53,260 KB
testcase_06 WA -
testcase_07 AC 38 ms
53,560 KB
testcase_08 AC 37 ms
52,620 KB
testcase_09 AC 42 ms
53,004 KB
testcase_10 AC 78 ms
72,384 KB
testcase_11 AC 75 ms
70,348 KB
testcase_12 AC 77 ms
70,860 KB
testcase_13 AC 122 ms
102,412 KB
testcase_14 AC 1,795 ms
110,124 KB
testcase_15 AC 645 ms
87,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i == n//i:
                continue
            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
    #print(a[i],div)
    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