結果

問題 No.390 最長の数列
ユーザー heabiheabi
提出日時 2020-11-22 12:19:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,214 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 171,900 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 22:43:44
合計ジャッジ時間 2,797 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;
// constexpr ll mod = 998244353;
// constexpr ll mod = 67280421310721;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

void pt_vvll(vvll v) {
    ll vs = v.size(), vs0 = v[0].size();
    rep(i, vs) {
        rep(j, vs0) {
            cout << v[i][j];

            if (j != vs0 - 1)
                cout << " ";
            else
                cout << "\n";
        }
    }
}
void pt_vll(vll v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];
        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}

vector<ll> divisor(ll n, vll &ret) {
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}

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

    ll N;
    cin >> N;
    vll x(N);
    vector<bool> exs(1000010);
    rep(i, N) {
        cin >> x[i];
        exs[x[i]] = true;
    }

    vector<bool> saw(1000010, false);
    ll ans = 1;
    for (ll i = 2; i < 1000010; i++) {
        if (saw[i]) continue;
        if (exs[i] == false) continue;
        ll now = i;
        ll sum = 0;
        for (ll j = now; j < 1000010; j += now) {
            if (exs[j]) {
                now = j;
                sum++;
            }
            saw[j] = true;
        }

        chmax(ans, sum);
    }

    if (exs[1] == true) ans++;
    cout << ans << "\n";
    return 0;
}
0