結果
問題 | No.979 Longest Divisor Sequence |
ユーザー |
|
提出日時 | 2020-01-31 22:05:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 465 ms / 2,000 ms |
コード長 | 969 bytes |
コンパイル時間 | 966 ms |
コンパイル使用メモリ | 101,268 KB |
実行使用メモリ | 39,404 KB |
最終ジャッジ日時 | 2024-11-14 22:05:16 |
合計ジャッジ時間 | 8,436 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> #include <limits> static constexpr int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using u64 = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; int main() { int n; cin >> n; int M = 300001; vector<vector<int>> B(M); vector<int> v(n); for (auto &&k : v) scanf("%d", &k); vector<int> dp(n, 1), dp2(M, 0); for (int i = 1; i < M; ++i) { for (int j = 2*i; j < M; j += i) { B[j].emplace_back(i); } } for (int i = 0; i < n; ++i) { dp2[v[i]] = max(dp2[v[i]], 1); for (auto &&j : B[v[i]]) { dp2[v[i]] = max(dp2[v[i]], dp2[j]+1); } } cout << *max_element(dp2.begin(),dp2.end()) << "\n"; return 0; }