結果
| 問題 |
No.1730 GCD on Blackboard in yukicoder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-18 02:49:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,193 bytes |
| コンパイル時間 | 1,037 ms |
| コンパイル使用メモリ | 99,692 KB |
| 実行使用メモリ | 14,336 KB |
| 最終ジャッジ日時 | 2024-12-24 14:11:16 |
| 合計ジャッジ時間 | 14,215 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 9 RE * 9 TLE * 1 |
ソースコード
#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 co[1000010] = {}, a[200020];
int d[200020] = {};
int 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) {
if (d[j] == 0) {
d[j] = i;
}
}
}
}
set<int> st, st1;
for (int i = 0; i < n; i++) {
int now = a[i];
while (now != 1) {
for (auto j = st.begin(); j != st.end(); j++) {
st1.insert(*j * d[now]);
}
st1.insert(d[now]);
for (auto j = st1.begin(); j != st1.end(); j++) {
st.insert(*j);
}
now = now / d[now];
}
for (auto j = st.begin(); j != st.end(); j++) {
co[*j]++;
}
st.clear();
st1.clear();
}
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;
}
}