結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
![]() |
提出日時 | 2020-01-31 21:55:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 507 ms / 2,000 ms |
コード長 | 666 bytes |
コンパイル時間 | 2,133 ms |
コンパイル使用メモリ | 198,100 KB |
最終ジャッジ日時 | 2025-01-08 21:05:08 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE signed main(){ int n; cin>>n; vector<int> as(n); for(int i=0;i<n;i++) cin>>as[i]; const int MAX = 3e5 + 100; vector< vector<int> > G(MAX); for(int i=1;i<MAX;i++) for(int j=i+i;j<MAX;j+=i) G[j].emplace_back(i); vector<int> dp(MAX,-MAX); int ans=0; for(int a:as){ chmax(dp[a],1); for(int d:G[a]) chmax(dp[a],dp[d]+1); chmax(ans,dp[a]); } cout<<ans<<endl; return 0; }