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 n, t[300005], g[300005];
vector < pair < int, int > > h;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)  scanf("%d", &t[i]);

    sort(t, t + n);

    for (int i = 1, j = 1; i <= n; ++i)
    {
        if (t[i] != t[i - 1])
        {
            ++g[j];
            j = 1;
        }
        else ++j;
    }
    for (int i = n; i > 0; --i)
    {
        if (g[i] != 0)
            h.push_back({i, g[i]});
    }
    printf("%d ", n);
    for (int i = 2; i <= n; ++i)
    {
        int k = 0;
        for (auto j : h)
        {
            int l = j.first - (j.first % i);
            l *= j.second;
            k += l;
            if (i == j.first)  h.pop_back();
        }
        printf("%d ", k);
    }
    return 0;
}