結果

問題 No.979 Longest Divisor Sequence
ユーザー chineristACchineristAC
提出日時 2020-06-18 02:50:30
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 535 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 86,516 KB
実行使用メモリ 125,316 KB
最終ジャッジ日時 2023-09-16 11:54:09
合計ジャッジ時間 5,538 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,900 KB
testcase_01 AC 71 ms
71,140 KB
testcase_02 AC 73 ms
71,140 KB
testcase_03 AC 71 ms
71,284 KB
testcase_04 AC 70 ms
70,984 KB
testcase_05 AC 70 ms
70,988 KB
testcase_06 AC 70 ms
71,108 KB
testcase_07 AC 70 ms
71,140 KB
testcase_08 AC 70 ms
71,140 KB
testcase_09 AC 71 ms
70,992 KB
testcase_10 AC 136 ms
79,096 KB
testcase_11 AC 109 ms
78,912 KB
testcase_12 AC 113 ms
79,056 KB
testcase_13 AC 163 ms
121,760 KB
testcase_14 TLE -
testcase_15 AC 762 ms
92,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

import sys

input=sys.stdin.buffer.readline

N=int(input())
A=list(map(int,input().split()))

data=[0]*(max(A)+1)
for i in range(N):
    test=1
    d=divisors(A[i])
    for D in d:
        if D!=A[i]:
            test=max(test,data[D]+1)
    data[A[i]]=max(data[A[i]],test)

print(max(data))
0