結果

問題 No.2218 Multiple LIS
ユーザー titiatitia
提出日時 2023-02-17 22:43:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 254 ms / 3,000 ms
コード長 1,055 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 92,952 KB
最終ジャッジ日時 2023-09-26 20:02:13
合計ジャッジ時間 7,916 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
78,720 KB
testcase_01 AC 86 ms
78,792 KB
testcase_02 AC 86 ms
78,736 KB
testcase_03 AC 86 ms
78,540 KB
testcase_04 AC 87 ms
78,736 KB
testcase_05 AC 87 ms
78,788 KB
testcase_06 AC 87 ms
78,772 KB
testcase_07 AC 90 ms
78,800 KB
testcase_08 AC 88 ms
78,904 KB
testcase_09 AC 86 ms
79,008 KB
testcase_10 AC 91 ms
78,796 KB
testcase_11 AC 85 ms
78,900 KB
testcase_12 AC 100 ms
79,032 KB
testcase_13 AC 108 ms
79,536 KB
testcase_14 AC 99 ms
79,152 KB
testcase_15 AC 102 ms
79,212 KB
testcase_16 AC 87 ms
78,856 KB
testcase_17 AC 108 ms
79,748 KB
testcase_18 AC 90 ms
78,884 KB
testcase_19 AC 88 ms
78,872 KB
testcase_20 AC 106 ms
79,716 KB
testcase_21 AC 130 ms
79,876 KB
testcase_22 AC 147 ms
83,552 KB
testcase_23 AC 174 ms
86,488 KB
testcase_24 AC 119 ms
80,012 KB
testcase_25 AC 192 ms
87,612 KB
testcase_26 AC 211 ms
92,556 KB
testcase_27 AC 220 ms
92,616 KB
testcase_28 AC 207 ms
92,368 KB
testcase_29 AC 220 ms
92,952 KB
testcase_30 AC 218 ms
92,296 KB
testcase_31 AC 175 ms
91,976 KB
testcase_32 AC 183 ms
92,316 KB
testcase_33 AC 184 ms
92,232 KB
testcase_34 AC 183 ms
92,236 KB
testcase_35 AC 179 ms
92,236 KB
testcase_36 AC 107 ms
91,596 KB
testcase_37 AC 254 ms
92,744 KB
testcase_38 AC 86 ms
78,844 KB
testcase_39 AC 87 ms
78,948 KB
testcase_40 AC 211 ms
92,476 KB
testcase_41 AC 214 ms
92,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

# エラトステネスの篩を用いた素因数分解・約数列挙
MAX=2*10**5+10 # 使いたい最大値を指定

# Sieve[i]で、iの最も小さい約数を返す。
Sieve=[i for i in range(MAX)]

for i in range(2,MAX):
    if Sieve[i]!=i:
        continue
    
    for j in range(i,MAX,i):
        if Sieve[j]==j:
            Sieve[j]=i

# 素因数分解
def fact(x):
    D=dict()
    while x!=1:
        k=Sieve[x]
        if k in D:
            D[k]+=1
        else:
            D[k]=1
        x//=k
    return D

# 約数列挙
def faclist(x):
    LIST=[1]
    while x!=1:
        k=Sieve[x]
        count=0
        while x%k==0:
            count+=1
            x//=k

        LIST2=[]
        for l in LIST:
            for i in range(1,count+1):
                LIST2.append(l*k**i)
        LIST+=LIST2

    return LIST

DP=[0]*(111111)

for a in A:
    MAX=0
    for v in faclist(a):
        MAX=max(MAX,DP[v]+1)
    DP[a]=MAX

print(max(DP))


0