1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <set>
#include <unordered_set>
#include <vector>

using namespace std;
const int MAXN = 300006;
int result[MAXN] = {0};

int main()
{
	int n;
	cin >> n;
	unordered_set<int> unorderedSet;
	multiset<int> multiSet;
	vector<int> counts;

	for (int i = 0; i < n; ++i)
	{
		int num;
		cin >> num;
		unorderedSet.insert(num);
		multiSet.insert(num);
	}

	for (int num : unorderedSet)
	{
		int count = multiSet.count(num);
		counts.push_back(count);
	}

	result[1] = n;
	for (int i = 0; i < counts.size(); ++i)
	{
		for (int j = 2; j < counts[i] + 1; j++)
		{
			result[j] += counts[i] / j;
		}
	}

	for (int j = 1; j < n + 1; j++)
	{
		cout << (result[j] * j) << " ";
	}

	return 0;
}