結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
![]() |
提出日時 | 2020-03-09 20:40:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 499 ms / 2,000 ms |
コード長 | 561 bytes |
コンパイル時間 | 1,594 ms |
コンパイル使用メモリ | 171,020 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 06:21:15 |
合計ジャッジ時間 | 3,434 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> dp(3e5 + 1, 0); for (auto&& x : a) { for (int i = 1; i * i <= x; i++) { if (x % i == 0) { int j = x / i; if (i < x) dp[x] = max(dp[x], dp[i] + 1); if (j < x) dp[x] = max(dp[x], dp[j] + 1); } } dp[x] = max(dp[x], 1); } cout << *max_element(begin(dp), end(dp)) << endl; }