結果

問題 No.979 Longest Divisor Sequence
ユーザー face4face4
提出日時 2020-01-31 22:10:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 71,812 KB
実行使用メモリ 4,408 KB
最終ジャッジ日時 2023-10-17 09:59:56
合計ジャッジ時間 3,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

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