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

using namespace std;

int main() {

	int n; cin >> n;

	unordered_map<int, int> znaczki, f; int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		znaczki[a - 1]++;
	}

	vector<int> K(n + 1, 0);
	for (auto& x : znaczki) {
		//cout << x.second << endl;
		K[x.second]++;
	}

	vector<int> N(n + 1, 0);
	N[n] = K[n];
	for (int i = n-1; i >= 0; i--) {
		N[i] = N[i + 1] + K[i];
	}

	/*for (int i = 0; i <= n; i++) {
		cout << i << ": " << N[i] << endl;
	}*/

	long long res = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; i * j <= n; j++) {
			res += N[i * j];
		}
		res *= 1LL * i;
		cout << res << ' ';
		res = 0;
	}

	return 0;
}