結果
| 問題 | 
                            No.979 Longest Divisor Sequence
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Salmonize
                         | 
                    
| 提出日時 | 2020-06-04 14:52:21 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,591 ms / 2,000 ms | 
| コード長 | 575 bytes | 
| コンパイル時間 | 367 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 85,960 KB | 
| 最終ジャッジ日時 | 2024-11-29 02:35:25 | 
| 合計ジャッジ時間 | 18,891 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 | 
ソースコード
import sys
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
def solve():
    n = ni()
    a = nl()
    m = 3 * 10 ** 5 + 5
    g = [list() for _ in range(m)]
    for i in range(1, m):
        for j in range(i*2, m, i):
            g[j].append(i)
    c = [-1]*m
    c[1] = 0
    for x in a:
        if x == 1:
            c[x] = 1
        else:
            c[x] = max([c[y] for y in g[x]]) + 1
    print(max(c))
    return
solve()
            
            
            
        
            
Salmonize