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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>

#define B 300001
int counters[B];
int cc[B];

int c;

#define SKIP_WHITESPACE \
{   \
    while (1) { \
        c = fgetc(stdin);   \
        if (c != ' ' && c != '\n' && c != '\r') \
            break;  \
    }   \
}   \

#define READ_INT    \
({   \
    SKIP_WHITESPACE \
    int ret = c - '0';  \
    while (1) { \
        c = fgetc(stdin);   \
        if (c < '0' || c > '9') \
            break;  \
        ret = ret * 10 + c - '0';   \
    }   \
    ret; \
})   \

int main(int argc, char* argv[]) {
    std::ios_base::sync_with_stdio (false);
    std::map<int, int> buckets;

    int n;
    n = READ_INT;

    int i, j, x, m = 0;
    for (i = 0; i < n; ++i) {
        x = READ_INT;
        counters[buckets[x]]--;
        buckets[x]++;
        counters[buckets[x]]++;
        if (buckets[x] > m)
            m = buckets[x];
    }

    int d = 0;
    for (i = 1; i <= m; ++i) {
        if (counters[i]) {
            cc[d++] = i;
        }
    }

    int s;
    for (i = 1; i <= n; ++i) {
        s = 0;
        for (j = 0; j < d; ++j) {
            s += (cc[j] - (cc[j] % i)) * counters[cc[j]];
        }
        std::cout << s;
        if (i < n)
            std::cout << " ";
    }
    return EXIT_SUCCESS;
}