結果

問題 No.979 Longest Divisor Sequence
ユーザー kumatan400kumatan400
提出日時 2021-12-24 06:37:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,538 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 81,568 KB
実行使用メモリ 145,796 KB
最終ジャッジ日時 2023-10-19 07:00:56
合計ジャッジ時間 4,612 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
59,168 KB
testcase_01 AC 46 ms
59,168 KB
testcase_02 AC 43 ms
59,168 KB
testcase_03 AC 46 ms
59,168 KB
testcase_04 AC 44 ms
59,168 KB
testcase_05 AC 44 ms
59,168 KB
testcase_06 AC 45 ms
59,168 KB
testcase_07 AC 44 ms
59,168 KB
testcase_08 AC 45 ms
59,168 KB
testcase_09 AC 44 ms
59,168 KB
testcase_10 AC 88 ms
75,476 KB
testcase_11 AC 85 ms
75,224 KB
testcase_12 AC 88 ms
75,244 KB
testcase_13 AC 151 ms
123,892 KB
testcase_14 AC 1,538 ms
145,796 KB
testcase_15 AC 677 ms
99,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def d(K):
    if K == 1:
        return [0]

    res = []
    i = 1
    while i * i <= K:
        if K % i == 0:
            if i != K:
                res.append(i)
            j = K // i
            if i != j and j != K:
                res.append(j)
        i += 1
    return res


Z = 3 * 10**5
L = [0] * (Z+1)


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

R = {}
for a in A:
    if not a in R:
        R[a] = d(a)



for a in A:
    M = max(L[r] for r in R[a])
    L[a] = M + 1


ans = max(L)
print(ans)
0