結果
| 問題 |
No.1730 GCD on Blackboard in yukicoder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-18 02:08:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,183 bytes |
| コンパイル時間 | 1,149 ms |
| コンパイル使用メモリ | 100,476 KB |
| 実行使用メモリ | 123,008 KB |
| 最終ジャッジ日時 | 2024-12-24 12:53:08 |
| 合計ジャッジ時間 | 11,194 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 1 |
| other | AC * 5 RE * 19 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[200020], d[200020] = {};
vector<set<int>> st(200020);
int co[1000010] = {};
long long ans[200020] = {};
int main() {
int n;
cin >> n;
int m = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
m = max(m, a[i]);
}
for (int i = 2; i <= m; i++) {
if (d[i] == 0) {
for (int j = i; j <= m; j += i) {
d[j] = i;
}
}
}
for (int i = 0; i < n; i++) {
int now = a[i];
set<int> st1;
while (now != 1) {
for (auto j = st[i].begin(); j != st[i].end(); j++) {
st1.insert(*j * d[now]);
}
st1.insert(d[now]);
for (auto j = st1.begin(); j != st1.end(); j++) {
st[i].insert(*j);
}
now = now / d[now];
}
for (auto j = st[i].begin(); j != st[i].end(); j++) {
co[*j]++;
}
}
for (int i = 2; i <= m; i++) {
ans[min(n, co[i])] = i;
}
ans[n + 1] = 1;
for (int i = n; i > 0; i--) {
ans[i] = max(ans[i], ans[i + 1]);
cout << ans[i] << endl;
}
}