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
46
47
48
49
50
#include <iostream>
#include <algorithm>
using namespace std;

const int mx = 3e5+5;

int t[mx];
int counter[mx];
int ans[mx];
int n;

int main(){
    ios::sync_with_stdio(false);

    cin >> n;
    for(int i = 0; i < n; ++i){
        cin>>t[i];
    }

    sort(t, t+n);

    int last = t[0];
    int times = 1;
    for(int i = 1; i < n; ++i){
        if(t[i] != last){
            ++counter[times];
            last = t[i];
            times = 1;
        }
        else{
            ++times;
        }
    }
    ++counter[times];

    for(int i = 1; i <= n; ++i){
        if(counter[i] > 0){
            for(int j = 1; j <= i; ++j){
                ans[j] += (i / j) * counter[i];
            }
        }
    }

    for(int i = 1; i <= n; ++i){
        cout << ans[i] * i << " ";
    }


    return 0;
}