結果

問題 No.979 Longest Divisor Sequence
ユーザー face4face4
提出日時 2020-01-31 22:14:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 599 ms
コンパイル使用メモリ 72,072 KB
実行使用メモリ 4,392 KB
最終ジャッジ日時 2023-10-17 10:05:42
合計ジャッジ時間 2,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,392 KB
testcase_01 AC 2 ms
4,392 KB
testcase_02 AC 2 ms
4,392 KB
testcase_03 AC 2 ms
4,392 KB
testcase_04 AC 2 ms
4,392 KB
testcase_05 AC 3 ms
4,392 KB
testcase_06 AC 3 ms
4,392 KB
testcase_07 AC 2 ms
4,392 KB
testcase_08 AC 3 ms
4,392 KB
testcase_09 AC 3 ms
4,392 KB
testcase_10 AC 7 ms
4,392 KB
testcase_11 AC 7 ms
4,392 KB
testcase_12 AC 7 ms
4,392 KB
testcase_13 AC 48 ms
4,392 KB
testcase_14 AC 495 ms
4,392 KB
testcase_15 AC 166 ms
4,392 KB
権限があれば一括ダウンロードができます

ソースコード

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