結果

問題 No.390 最長の数列
ユーザー はむ吉🐹
提出日時 2016-07-12 13:04:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,732 ms / 5,000 ms
コード長 692 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 82,660 KB
実行使用メモリ 97,472 KB
最終ジャッジ日時 2024-10-02 10:54:00
合計ジャッジ時間 16,382 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import array
import math


MAX_X = 10 ** 6


def divisors_without_self(n, typecode="L"):
    ds = array.array(typecode)
    if n != 1:
        for i in range(1, math.floor(math.sqrt(n)) + 1):
            r, m = divmod(n, i)
            if m == 0:
                ds.append(i)
                if i != 1 and i != r:
                    ds.append(r)
    return ds


def main():
    _ = input()
    xs = sorted(map(int, input().split()))
    dp = array.array("L", (0 for _ in range(MAX_X + 1)))
    for x in xs:
        dp[x] = 1
        for y in divisors_without_self(x):
            dp[x] = max(dp[x], dp[y] + 1)
    print(max(dp))


if __name__ == '__main__':
    main()
0