結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
Rubikun
|
| 提出日時 | 2020-01-31 21:51:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 356 ms / 2,000 ms |
| コード長 | 828 bytes |
| コンパイル時間 | 1,566 ms |
| コンパイル使用メモリ | 169,388 KB |
| 実行使用メモリ | 8,376 KB |
| 最終ジャッジ日時 | 2024-09-17 07:53:46 |
| 合計ジャッジ時間 | 2,720 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int N;cin>>N;
vector<int> A(N);
vector<int> B(1000001,0);
for(int i=0;i<N;i++){
cin>>A[i];
}
for(int i=0;i<N;i++){
if(A[i]==1){
B[1]=1;
continue;
}
int maxi=B[1];
for(int j=2;j*j<=A[i];j++){
if(A[i]%j==0){
maxi=max({maxi,B[j],B[A[i]/j]});
}
}
B[A[i]]=maxi+1;
}
int ans=0;
for(int i=0;i<1000001;i++){
ans=max(ans,B[i]);
}
cout<<ans<<endl;
}
Rubikun