結果

問題 No.979 Longest Divisor Sequence
ユーザー roarisroaris
提出日時 2020-07-25 23:39:29
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 421 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 124,436 KB
最終ジャッジ日時 2023-09-10 02:13:15
合計ジャッジ時間 5,848 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
77,556 KB
testcase_01 AC 76 ms
77,416 KB
testcase_02 AC 76 ms
77,416 KB
testcase_03 AC 76 ms
77,432 KB
testcase_04 AC 76 ms
77,480 KB
testcase_05 AC 77 ms
77,228 KB
testcase_06 AC 77 ms
77,532 KB
testcase_07 AC 77 ms
77,532 KB
testcase_08 AC 77 ms
77,440 KB
testcase_09 AC 75 ms
77,380 KB
testcase_10 AC 106 ms
78,876 KB
testcase_11 AC 104 ms
78,864 KB
testcase_12 AC 103 ms
78,652 KB
testcase_13 AC 126 ms
124,436 KB
testcase_14 TLE -
testcase_15 AC 745 ms
92,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
dp = [0]*(3*10**5+10)

for Ai in A:
    dp[Ai] = 1
    
    if Ai==1:
        continue
    
    i = 1
    
    while i*i<=Ai:
        if Ai%i==0:
            if i==1:
                dp[Ai] = max(dp[Ai], dp[i]+1)
            else:
                dp[Ai] = max(dp[Ai], dp[i]+1, dp[Ai//i]+1)
        
        i += 1

print(max(dp))
0