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
#include<bits/stdc++.h>
using namespace std;
map<int, int> amount;
int pref[600006];
int main()
{
	int n;
	cin >> n;
	pref[0]=n;
	for(int i=0; i<n; i++)
	{
		int p, l;
		cin >> p;
		l=amount[p];
		amount[p]++;
		pref[l]--;
		pref[l+1]++;
	}
	for(int i=n+5; i>0; i--)
	{
		pref[i]=pref[i+1]+pref[i];
	}
	for(int i=1; i<(n+1); i++)
	{
		int pointer=(n/i), W=0;
		while(pointer>0)
		{
			W+=(pref[pointer*i]-pref[(pointer+1)*i])*pointer*i;
			pointer--;
		}
		cout << W << " ";
	}
}