結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
|
| 提出日時 | 2020-02-01 16:42:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,311 ms / 2,000 ms |
| コード長 | 629 bytes |
| コンパイル時間 | 1,651 ms |
| コンパイル使用メモリ | 169,512 KB |
| 実行使用メモリ | 7,872 KB |
| 最終ジャッジ日時 | 2024-09-18 20:06:00 |
| 合計ジャッジ時間 | 4,185 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N; cin >> N;
vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
vector<ll> dp(300005, 0);
for (int i = 0; i < N; i++) {
ll t = A[i], temp = 0;
for (int j = 1; j <= sqrt(t); j++) {
if (t % j) continue;
ll f1 = j, f2 = t / j;
if (f1 < t) temp = max(temp, dp[f1]);
if (f2 < t) temp = max(temp, dp[f2]);
}
dp[t] = temp + 1;
}
ll ans = 0;
for (int i = 0; i < 300005; i++) {
ans = max(ans, dp[i]);
}
cout << ans << '\n';
return 0;
}