結果

問題 No.2218 Multiple LIS
ユーザー titiatitia
提出日時 2023-02-17 22:42:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,125 ms / 3,000 ms
コード長 1,055 bytes
コンパイル時間 774 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 19,944 KB
最終ジャッジ日時 2023-09-26 20:01:11
合計ジャッジ時間 21,921 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
15,924 KB
testcase_01 AC 148 ms
15,944 KB
testcase_02 AC 154 ms
15,892 KB
testcase_03 AC 155 ms
15,948 KB
testcase_04 AC 151 ms
15,992 KB
testcase_05 AC 152 ms
15,800 KB
testcase_06 AC 154 ms
15,984 KB
testcase_07 AC 152 ms
15,832 KB
testcase_08 AC 149 ms
15,804 KB
testcase_09 AC 149 ms
15,812 KB
testcase_10 AC 156 ms
15,788 KB
testcase_11 AC 150 ms
15,892 KB
testcase_12 AC 156 ms
15,904 KB
testcase_13 AC 151 ms
16,008 KB
testcase_14 AC 157 ms
16,004 KB
testcase_15 AC 150 ms
15,964 KB
testcase_16 AC 150 ms
15,872 KB
testcase_17 AC 153 ms
15,968 KB
testcase_18 AC 154 ms
15,884 KB
testcase_19 AC 150 ms
15,900 KB
testcase_20 AC 150 ms
15,896 KB
testcase_21 AC 197 ms
16,124 KB
testcase_22 AC 475 ms
17,292 KB
testcase_23 AC 730 ms
19,012 KB
testcase_24 AC 261 ms
16,512 KB
testcase_25 AC 780 ms
19,304 KB
testcase_26 AC 1,073 ms
19,904 KB
testcase_27 AC 1,053 ms
19,864 KB
testcase_28 AC 1,037 ms
19,772 KB
testcase_29 AC 1,048 ms
19,944 KB
testcase_30 AC 1,063 ms
19,864 KB
testcase_31 AC 733 ms
18,284 KB
testcase_32 AC 722 ms
18,336 KB
testcase_33 AC 720 ms
18,220 KB
testcase_34 AC 720 ms
18,296 KB
testcase_35 AC 736 ms
18,152 KB
testcase_36 AC 236 ms
17,296 KB
testcase_37 AC 2,125 ms
19,788 KB
testcase_38 AC 148 ms
15,876 KB
testcase_39 AC 152 ms
15,856 KB
testcase_40 AC 1,149 ms
19,908 KB
testcase_41 AC 1,148 ms
19,864 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