結果

問題 No.2218 Multiple LIS
ユーザー ニックネームニックネーム
提出日時 2023-02-17 21:45:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 257 ms / 3,000 ms
コード長 1,362 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 89,164 KB
最終ジャッジ日時 2023-09-26 18:59:13
合計ジャッジ時間 7,738 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,948 KB
testcase_01 AC 75 ms
75,812 KB
testcase_02 AC 76 ms
75,720 KB
testcase_03 AC 75 ms
75,908 KB
testcase_04 AC 74 ms
75,648 KB
testcase_05 AC 74 ms
75,856 KB
testcase_06 AC 75 ms
76,016 KB
testcase_07 AC 73 ms
75,840 KB
testcase_08 AC 73 ms
75,836 KB
testcase_09 AC 75 ms
75,644 KB
testcase_10 AC 74 ms
75,648 KB
testcase_11 AC 76 ms
76,116 KB
testcase_12 AC 80 ms
77,084 KB
testcase_13 AC 102 ms
77,688 KB
testcase_14 AC 92 ms
77,164 KB
testcase_15 AC 93 ms
77,352 KB
testcase_16 AC 75 ms
76,096 KB
testcase_17 AC 101 ms
77,636 KB
testcase_18 AC 75 ms
75,884 KB
testcase_19 AC 79 ms
75,980 KB
testcase_20 AC 97 ms
78,172 KB
testcase_21 AC 125 ms
78,648 KB
testcase_22 AC 168 ms
81,408 KB
testcase_23 AC 188 ms
84,168 KB
testcase_24 AC 143 ms
78,880 KB
testcase_25 AC 201 ms
84,728 KB
testcase_26 AC 234 ms
88,464 KB
testcase_27 AC 247 ms
88,560 KB
testcase_28 AC 249 ms
88,228 KB
testcase_29 AC 251 ms
88,476 KB
testcase_30 AC 234 ms
88,660 KB
testcase_31 AC 183 ms
88,128 KB
testcase_32 AC 184 ms
88,000 KB
testcase_33 AC 188 ms
87,892 KB
testcase_34 AC 184 ms
87,948 KB
testcase_35 AC 177 ms
88,120 KB
testcase_36 AC 87 ms
83,524 KB
testcase_37 AC 257 ms
89,164 KB
testcase_38 AC 76 ms
75,720 KB
testcase_39 AC 76 ms
75,844 KB
testcase_40 AC 206 ms
88,452 KB
testcase_41 AC 207 ms
88,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class PrimeNumbers:
    def __init__(self,nmax):
        rootnmax = isqrt(nmax)
        self.prime_judgement = [True]*(rootnmax+1)
        self.prime_judgement[0] = self.prime_judgement[1] = False
        for i in range(2,rootnmax+1):
            if self.prime_judgement[i]:
                for j in range(2,rootnmax//i+1):
                    self.prime_judgement[i*j] = False
        self.prime_list = []
        for i,flag in enumerate(self.prime_judgement):
            if flag: self.prime_list.append(i)
    def prime_factorization(self,n):
        return_list = []
        for i in self.prime_list:
            if n==1 or i*i>n: break
            if n%i==0:
                return_list.append([i,0])
                while n%i==0: return_list[-1][1] += 1; n //= i
        if n!=1: return_list.append([n,1])
        return return_list
    def divisors_enumeration(self,n):
        divisors = [1]
        for p,v in self.prime_factorization(n):
            for i in range(len(divisors)):
                for j in range(v): divisors.append(divisors[i]*p**(j+1))
        return divisors
def isqrt(n):
    m = int(n**0.5)
    if m**2>n: m -= 1
    return m
n = int(input())
dp = [0]*(10**5+1)
pn = PrimeNumbers(10**5)
for v in map(int,input().split()):
    m = 0
    for d in pn.divisors_enumeration(v): m = max(m,dp[d])
    dp[v] = max(dp[v],m+1)
print(max(dp))
0