結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
Rubikun
|
| 提出日時 | 2020-01-31 21:47:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 1,454 ms |
| コンパイル使用メモリ | 170,056 KB |
| 実行使用メモリ | 8,376 KB |
| 最終ジャッジ日時 | 2024-09-17 07:35:34 |
| 合計ジャッジ時間 | 2,992 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 2 |
ソースコード
#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;
ll rui(ll a,ll b){
ll ans=1;
while(b>0){
if(b&1) ans=ans*a%mod;
a=a*a%mod;
b/=2;
}
return ans;
}
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++){
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