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
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
const int N = 300001;
int result[N];
int n, a, sum;
map<int, int> input;
vector<int> nums;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		input[a]++;
	}
	map<int, int>::iterator it;
	for (it = input.begin(); it != input.end(); ++it) {
		nums.push_back(it->second);
	}
	result[1] = n;
	sort(nums.begin(), nums.end(), greater<int>());
	for (int i = 2; i <= n; i++) {
		for (int j = nums.size() - 1; j >= 0; j--) {
			if (nums[j] >= i) {
				result[i] += nums[j] - nums[j] % i;
			}
		}
		if (result[i] == 0)break;
	}
	for (int i = 1; i <= n; i++) {
		cout << result[i] << " ";
	}
	return 0;
}