結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
QCFium
|
| 提出日時 | 2020-01-31 22:12:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 547 bytes |
| コンパイル時間 | 1,521 ms |
| コンパイル使用メモリ | 170,836 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 08:30:10 |
| 合計ジャッジ時間 | 2,862 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 2 |
ソースコード
#include <bits/stdc++.h>
int ri() {
int n;
scanf("%d", &n);
return n;
}
int main() {
int n = ri();
int a[n];
for (auto &i : a) i = ri();
static int max[300001];
for (int i = 0; i < n; i++) {
std::vector<int> divs;
for (int j = 1; j * j <= a[i]; j++) {
if (a[i] % j == 0) {
divs.push_back(j);
if (j > 1) divs.push_back(a[i] / j);
}
}
int cur = 0;
for (auto j : divs) cur = std::max(cur, max[j]);
max[a[i]] = std::max(max[a[i]], cur + 1);
}
printf("%d\n", *std::max_element(max, max + 300001));
return 0;
}
QCFium