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

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	unordered_map<int, int> M;
	int n; cin >> n;

	for (int i = 1; i <= n; ++i) { int ai; cin >> ai; ++M[ai]; }

	unordered_map<int, int> ileWystapienIlosci;
	for (auto m : M) ++ileWystapienIlosci[m.second];

	for (int k = 1; k <= n; ++k)
	{
		//Roznych ilosci powinno byc <= sqrt(n), wiec mamy O(n*sqrt(n)) (bo 1+2+3+..+x = n )
		int suma = 0;
		for (auto m : ileWystapienIlosci) suma += m.second * (m.first / k * k);
		cout << suma << ' ';
	}
	cout << endl;
	
	return 0;
}