結果

問題 No.979 Longest Divisor Sequence
ユーザー vwxyzvwxyz
提出日時 2024-04-21 15:49:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 521 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 46,184 KB
最終ジャッジ日時 2024-04-21 15:49:06
合計ジャッジ時間 5,381 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
16,384 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 27 ms
10,880 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 173 ms
13,312 KB
testcase_11 AC 181 ms
13,312 KB
testcase_12 AC 181 ms
13,184 KB
testcase_13 AC 530 ms
16,116 KB
testcase_14 TLE -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def Divisors(N):
    divisors=[]
    for i in range(1,N+1):
        if i**2>=N:
            break
        elif N%i==0:
            divisors.append(i)
    if i**2==N:
        divisors+=[i]+[N//i for i in divisors[::-1]]
    else:
        divisors+=[N//i for i in divisors[::-1]]
    return divisors

N=int(input())
A=list(map(int,input().split()))
max_A=max(A)
dp=[-1]*(max_A+1)
dp[0]=0
for a in A:
    for d in Divisors(a)+[0]:
        if a==d:
            continue
        dp[a]=max(dp[a],dp[d]+1)
ans=max(dp)
print(ans)
0