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 <algorithm>

const int MAXN = 300000+5;
const int INF = 1000000000+5;
int K[MAXN];
int C[MAXN];
int n;

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin >> n;
    for (int i=0;i<n;++i) std::cin >> K[i];
    K[n] = INF;
    std::sort(K,K+n);

    int b = 0;
    for (int i=1;i<=n;++i) {
        if (K[i-1] != K[i]) {
            int c = i-b;
            for (int k=1;k<=c;++k) C[k] += c - c%k;
            b=i;
        }
    }

    for (int i=1;i<=n;++i) std::cout << (i==1 ? "" : " ") << C[i];
    std::cout << std::endl;
    return 0;
}