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
#include <iostream>
#include <ranges>
#include <unordered_map>
#include <map>

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    uint32_t n;
    cin >> n;
    uint32_t temp;
    unordered_map<uint32_t, int> counts; // city - count

    for (int i = 0; i < n; ++i) {
        cin >> temp;
        counts[temp]++;
    }
    map<uint32_t, uint32_t> counts_count;
    for (auto [city, count] : counts) {
        counts_count[count]++;
    }

    for (int k = 1; k < n + 1; ++k) {
        uint32_t sum = 0;
        uint32_t foo;

//        cout << k << '\n';
        for (auto [count, counts_c] : std::ranges::reverse_view(counts_count)) {
//            cout << count << ' ' << counts_c << '\n';
            foo = (count / k) * counts_c;
            if (foo == 0) {
                break;
            }
            sum += foo * k;
        }
        cout << sum << ' ';
    }

    return 0;
}