結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
|
提出日時 | 2020-02-01 16:41:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 617 bytes |
コンパイル時間 | 1,412 ms |
コンパイル使用メモリ | 168,776 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-09-18 20:05:56 |
合計ジャッジ時間 | 3,557 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 2 |
ソースコード
#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; 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; }