結果
| 問題 |
No.979 Longest Divisor Sequence
|
| コンテスト | |
| ユーザー |
set0gut1
|
| 提出日時 | 2020-01-31 22:24:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,358 ms / 2,000 ms |
| コード長 | 928 bytes |
| コンパイル時間 | 735 ms |
| コンパイル使用メモリ | 92,676 KB |
| 実行使用メモリ | 13,368 KB |
| 最終ジャッジ日時 | 2024-09-17 08:52:05 |
| 合計ジャッジ時間 | 3,185 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
void solve() {
ll N;
cin >> N;
unordered_map<ll, ll> memo;
rep (i, N) {
ll A;
cin >> A;
if (A == 1) memo[1] = 1;
else if (memo[A] == 0 or memo[A] == 1) memo[A] = memo[1] + 1;
for (ll it = 2; it * it <= A; it++) {
if (A % it) continue;
ll tmp = max(memo[it] + 1, memo[A / it] + 1);
if (tmp > memo[A]) memo[A] = tmp;
}
}
ll ans = 0;
for (auto it: memo) if (ans < it.second) ans = it.second;
cout << ans << endl;
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
cout.precision(12);
cout << fixed;
solve();
return 0;
}
set0gut1