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
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector <int> v(n);
	vector <int> temp(n);
	for (int i = 0; i < n; i++) {
		cin >> temp[i];
	}
	sort(temp.begin(), temp.end());
	vector <int> w;
	int ile = 0;
	for (int i = 0; i < n; i++) {
		if (i && temp[i] != temp[i-1]) {
			w.push_back(ile);
			ile = 0;
		}
		ile++;
	}
	w.push_back(ile);
	vector <int> res(n);
	for (int i = 0; i < (int)w.size(); i++) {
		for (int j = w[i]; j >= 1; j--) {
			res[j-1] += w[i]/j - w[i]/(j+1);
//			cout << w[i] << " " << j << ":\n";
//			cout << w[i]/j << " " << w[i]/j << " " << w[i]/(j+1) << "\n";
		}
	}
	for (int i = n-1; i >= 0; i--) {
		if (i != n-1)
			res[i] += (res[i+1] / (i+2));
		res[i] *= (i+1);
	}
	for (auto i : res)
		cout << i << " ";
}