結果

問題 No.390 最長の数列
ユーザー s_shohei
提出日時 2020-06-14 16:08:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,594 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 106,240 KB
最終ジャッジ日時 2024-06-27 12:05:54
合計ジャッジ時間 9,923 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
x = list(map(int, input().split()))
def m_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

from collections import defaultdict
d = defaultdict(int)
for num in x:
    d[num]=1

x.sort(reverse=True)
for num in x:
    now_len=d[num] # must be 1 or greater
    for div in m_div(num):
        if div==num or (not div in d):
            continue
        d[div] = max(d[div],now_len + 1)

print(max(d.values()))
0