結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 夜
提出日時 2021-11-18 02:49:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,193 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 98,908 KB
実行使用メモリ 11,572 KB
最終ジャッジ日時 2023-08-26 01:28:39
合計ジャッジ時間 11,458 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
5,472 KB
testcase_02 AC 13 ms
7,420 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
5,692 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
5,448 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 651 ms
7,452 KB
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 AC 261 ms
6,724 KB
testcase_24 TLE -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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