結果

問題 No.979 Longest Divisor Sequence
ユーザー titiatitia
提出日時 2020-01-31 22:33:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 789 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 205,812 KB
実行使用メモリ 4,816 KB
最終ジャッジ日時 2023-10-17 10:48:00
合計ジャッジ時間 4,052 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin>>N;

    vector<int> A(N);
    for (int i=0;i<N;i+=1){
        cin>>A[i];
    }

    vector<int> DP(100001);

    int x;
    int xr;
    for (int a=0;a<N;a+=1){
        x=A[a];

        xr=ceil(sqrt(x));
        vector<int> LIST;


        for (int i=1;i<xr+1;i+=1){
            if (x%i==0){
                LIST.push_back(i);
                LIST.push_back(x/i);
            }
        }


        int MAX=0;
        for (int i : LIST){

            if (i!=x){
                MAX=max(MAX,DP[i]);
            }
        }

        DP[x]=MAX+1;
    }


    int ANS=0;

    for (int i=0;i<100000+1;i+=1){
        ANS=max(ANS,DP[i]);
    }

    cout<<ANS<<endl;
}
0