結果

問題 No.390 最長の数列
ユーザー daleksprinterdaleksprinter
提出日時 2018-08-27 15:32:43
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 396 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 6,500 KB
実行使用メモリ 53,944 KB
最終ジャッジ日時 2023-09-17 03:49:02
合計ジャッジ時間 7,712 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
45,428 KB
testcase_01 AC 112 ms
45,432 KB
testcase_02 AC 121 ms
45,628 KB
testcase_03 AC 112 ms
45,548 KB
testcase_04 AC 112 ms
45,580 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

arr = map(int,raw_input().split())

arr.sort()

def divisor(n):
	ret = []
	i = 1
	while i ** 2 <= n : 
		if n % i == 0 :
			ret.append(i)
			if i ** 2 != n:
				ret.append(n/i)
		i += 1
	ret.sort()
	return ret

dp = [0 for i in range(10**6+1)]
for i in arr:
	dp[i] = 1
for i in arr:
	div = divisor(i)

	for k in div:
		if k != i:
			dp[i] = max(dp[i], dp[k] + 1)
	
print max(dp)
0