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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;

    int* a = new int[n];

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

    sort(a, a + n);

    /* for(int i = 0; i < n; ++i) {
        cout << a[i] << " ";
    }
    cout << "\n"; */

    vector<int> v;

    int cnt = 0;
    int curr = a[0];
    for(int i = 0; i < n; ++i) {
        if(a[i] == curr) {
            ++cnt;
        } else {
            curr = a[i];
            v.push_back(cnt);
            cnt = 1;
        }
    }
    v.push_back(cnt);
    sort(v.begin(), v.end());

    /* for(size_t i = 0; i < v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << "\n"; */

    /* int* s = new int[n + 1];
    for(int i = 0; i <= n; ++i) {
        s[i] = 0;
    }

    for(size_t i = 0; i < v.size(); ++i) {
        ++s[v[i]];
    }

    for(int i = 0; i <= n; ++i) {
        cout << s[i] << " ";
    }


    curr = n;
    
    for(int k = 2; k <= n; ++k) {
        cout << curr << " ";
    } */

    vector<pair<int, int>> stats;

    cnt = 0;
    curr = v[0];
    for(int i = 0; i < v.size(); ++i) {
        if(v[i] == curr) {
            ++cnt;
        } else {
            stats.push_back(make_pair(curr, cnt));
            curr = v[i];
            cnt = 1;
        }
    }
    stats.push_back(make_pair(curr, cnt));

    /* for(size_t i = 0; i < stats.size(); ++i) {
        cout << stats[i].first << ": " << stats[i].second << "\n";
    } */

    int g;
    for(int k = 1; k <= n; ++k) {
        g = n;
        for(auto p : stats) {
            g -= (p.first % k) * p.second;
        }
        cout << g << " ";
    }

    cout << "\n";
    return 0;
}