結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 夜
提出日時 2021-11-18 02:08:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,183 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 99,296 KB
実行使用メモリ 125,948 KB
最終ジャッジ日時 2023-08-26 00:34:09
合計ジャッジ時間 10,329 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 7 ms
14,136 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 7 ms
14,372 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 5 ms
14,652 KB
testcase_12 AC 5 ms
14,560 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 963 ms
125,948 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 282 ms
16,820 KB
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	}
}
0