結果

問題 No.979 Longest Divisor Sequence
ユーザー drken1215drken1215
提出日時 2020-01-31 23:01:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,525 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 174,172 KB
実行使用メモリ 14,688 KB
最終ジャッジ日時 2023-10-17 11:53:36
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



const int MAX = 310000;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    int res = 0;
    vector<int> num(MAX, 0);
    set<int> alr;
    for (auto a : A) {
        chmax(res, num[a] + 1);
        if (!alr.count(a)) {
            for (int b = a*2; b < MAX; b += a) {
                chmax(num[b], num[a] + 1);
            }
        }
        alr.insert(a);
    }
    cout << res << endl;
}
















0