結果

問題 No.979 Longest Divisor Sequence
ユーザー QCFiumQCFium
提出日時 2020-01-31 22:12:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 4,581 ms
コンパイル使用メモリ 169,736 KB
実行使用メモリ 6,148 KB
最終ジャッジ日時 2023-10-17 10:03:27
合計ジャッジ時間 3,459 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 9 ms
4,988 KB
testcase_11 AC 9 ms
4,984 KB
testcase_12 AC 9 ms
4,984 KB
testcase_13 WA -
testcase_14 AC 535 ms
6,148 KB
testcase_15 AC 180 ms
5,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	static int max[300001];
	for (int i = 0; i < n; i++) {
		std::vector<int> divs;
		for (int j = 1; j * j <= a[i]; j++) {
			if (a[i] % j == 0) {
				divs.push_back(j);
				if (j > 1) divs.push_back(a[i] / j);
			}
		}
		int cur = 0;
		for (auto j : divs) cur = std::max(cur, max[j]);
		max[a[i]] = std::max(max[a[i]], cur + 1);
	}
	printf("%d\n", *std::max_element(max, max + 300001));
	
  	return 0;
}
0