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
#include <cstdio>
#include <cstdlib>

#include <utility>
#include <vector>
#include <unordered_map>

int main() {
    unsigned int n;
    scanf("%d", &n);

    std::unordered_map<unsigned int, unsigned int> counts;
    std::vector<unsigned int> ret;

    ret.resize(n);

    for (int i = 0; i < n; i++) {
        unsigned int x;
        scanf("%u", &x);
        counts[x]++;
    }

    for (auto [k, v] : counts) {
        for (unsigned int j = 1; j <= v; j++) {
            ret[j - 1] += v - (v % j);
        }
    }

    printf("%u", ret[0]);
    for (unsigned int i = 1; i < n; i++) {
        printf(" %u", ret[i]);
    }

    putchar('\n');
    return 0;
}