結果

問題 No.979 Longest Divisor Sequence
ユーザー chocoruskchocorusk
提出日時 2020-01-31 21:48:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 1,046 ms
コンパイル使用メモリ 113,760 KB
実行使用メモリ 38,652 KB
最終ジャッジ日時 2023-10-17 09:20:43
合計ジャッジ時間 9,321 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 417 ms
37,448 KB
testcase_01 AC 417 ms
37,448 KB
testcase_02 AC 422 ms
37,448 KB
testcase_03 AC 406 ms
37,448 KB
testcase_04 WA -
testcase_05 AC 421 ms
37,448 KB
testcase_06 AC 426 ms
37,448 KB
testcase_07 AC 440 ms
37,448 KB
testcase_08 WA -
testcase_09 AC 452 ms
37,448 KB
testcase_10 AC 439 ms
37,460 KB
testcase_11 AC 434 ms
37,460 KB
testcase_12 AC 386 ms
37,460 KB
testcase_13 WA -
testcase_14 AC 544 ms
38,616 KB
testcase_15 AC 465 ms
37,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n;
	cin>>n;
	int a[300030];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	vector<int> g[300030];
	for(int d=1; d<=300000; d++){
		for(int i=2; i<=300000/d; i++){
			g[d*i].push_back(d);
		}
	}
	int dp[300030]={};
	for(int i=0; i<n; i++){
		for(auto y:g[a[i]]){
			dp[a[i]]=max(dp[a[i]], dp[y]+1);
		}
	}
	int ans=0;
	for(int i=1; i<=300000; i++) ans=max(ans, dp[i]);
	cout<<ans<<endl;
	return 0;
}
0