結果

問題 No.979 Longest Divisor Sequence
ユーザー qqqqqqqqqq
提出日時 2020-02-18 21:38:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,790 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 124,416 KB
最終ジャッジ日時 2024-04-16 04:15:53
合計ジャッジ時間 4,422 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
59,008 KB
testcase_01 AC 44 ms
59,264 KB
testcase_02 AC 44 ms
59,392 KB
testcase_03 AC 44 ms
59,904 KB
testcase_04 AC 44 ms
59,392 KB
testcase_05 AC 45 ms
59,136 KB
testcase_06 AC 45 ms
59,264 KB
testcase_07 AC 45 ms
59,392 KB
testcase_08 AC 45 ms
59,264 KB
testcase_09 AC 44 ms
59,136 KB
testcase_10 AC 81 ms
71,808 KB
testcase_11 AC 76 ms
69,888 KB
testcase_12 AC 80 ms
71,296 KB
testcase_13 AC 144 ms
124,416 KB
testcase_14 AC 1,790 ms
113,100 KB
testcase_15 AC 643 ms
92,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisor(n):
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if i*i != n:
                ret.append(n//i)
    return ret


n = int(input())
a = list(map(int, input().split()))

m = 3*10**5+1
DP = [0]*m

for ai in a:
    tmp = 0
    for bi in divisor(ai):
        if bi != ai:
            tmp = max(tmp, DP[bi])
    DP[ai] = tmp+1
print(max(DP))
0