結果

問題 No.979 Longest Divisor Sequence
ユーザー face4
提出日時 2020-01-31 22:14:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 500 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 72,692 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 08:32:13
合計ジャッジ時間 2,072 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> dp(300001, 0);
    for(int s = 0; s < n; s++){
        int x;  cin >> x;
        for(int i = 1; i*i <= x; i++){
            if(x%i) continue;
            int j = x/i;
            if(j < x)   dp[x] = max(dp[j]+1, dp[x]);
            j = i;
            if(j < x)   dp[x] = max(dp[j]+1, dp[x]);
        }
        dp[x] = max(dp[x], 1);
    }
    cout << *max_element(dp.begin(),dp.end()) << endl;
    return 0;
}
0