結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
hanbei_dayo
|
| 提出日時 | 2020-02-01 16:07:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 403 ms / 2,000 ms |
| コード長 | 920 bytes |
| コンパイル時間 | 793 ms |
| コンパイル使用メモリ | 84,556 KB |
| 実行使用メモリ | 5,504 KB |
| 最終ジャッジ日時 | 2024-09-18 20:04:54 |
| 合計ジャッジ時間 | 1,844 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
int dp[300010];
int main(){
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){
for(int j=1;j*j<=a[i];j++){
if(a[i]==1){
dp[a[i]]=1;
continue;
}
if(j==1)dp[a[i]]=max(dp[a[i]],dp[j]+1);
else{
if(a[i]%j==0){
dp[a[i]]=max(dp[a[i]],dp[j]+1);
dp[a[i]]=max(dp[a[i]],dp[a[i]/j]+1);
}
}
}
}
int ans = 0;
for(int i=0;i<300010;i++)ans=max(ans,dp[i]);
cout<<ans<<endl;
return 0;
}
hanbei_dayo