結果

問題 No.979 Longest Divisor Sequence
ユーザー vwxyzvwxyz
提出日時 2024-04-21 15:49:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,781 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 121,728 KB
最終ジャッジ日時 2024-04-21 15:49:17
合計ジャッジ時間 4,073 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,480 KB
testcase_01 AC 36 ms
51,968 KB
testcase_02 AC 36 ms
51,968 KB
testcase_03 AC 33 ms
52,480 KB
testcase_04 AC 33 ms
51,968 KB
testcase_05 AC 35 ms
52,224 KB
testcase_06 AC 37 ms
52,480 KB
testcase_07 AC 33 ms
52,280 KB
testcase_08 AC 36 ms
51,840 KB
testcase_09 AC 34 ms
51,840 KB
testcase_10 AC 99 ms
76,416 KB
testcase_11 AC 72 ms
75,868 KB
testcase_12 AC 70 ms
76,032 KB
testcase_13 AC 122 ms
121,728 KB
testcase_14 AC 1,781 ms
113,316 KB
testcase_15 AC 607 ms
92,160 KB
権限があれば一括ダウンロードができます

ソースコード

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