結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
ntuda
|
| 提出日時 | 2025-01-01 20:52:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 633 bytes |
| コンパイル時間 | 594 ms |
| コンパイル使用メモリ | 82,632 KB |
| 実行使用メモリ | 201,640 KB |
| 最終ジャッジ日時 | 2025-01-01 20:52:19 |
| 合計ジャッジ時間 | 5,119 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 1 |
ソースコード
from functools import lru_cache
@lru_cache(maxsize=300000)
def make_divisors(n):
divisors = [] #必要に応じてsetにしても良いかも
i = 1
while i ** 2 <= n:
if n % i == 0:
divisors.append(i)
if i ** 2 != n:
divisors.append(n//i)
i += 1
divisors.sort()
return divisors
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
dic = defaultdict(int)
for a in A:
tmp = 0
for x in make_divisors(a)[:-1]:
if x in dic:
tmp = max(tmp,dic[x])
dic[a] = tmp + 1
print(max(dic.values()))
ntuda