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
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

int main()
{
    int n = 0;
    std::cin >> n;
    
    std::unordered_map<int, int> tab;
    for (int i = 0; i < n; ++i)
    {
        int a;
        std::cin >> a;
        if (tab.find(a) == tab.end())
            tab[a] = 1;
        else
            ++tab[a];
    }

    int sums[n] = { 0 };
    for (auto [a, b] : tab)
    {
        for (int i = 1; i <= b; ++i)
            sums[i - 1] += (b / i) * i;
    }
    for (int i = 0; i < n; ++i)
        std::cout << sums[i] << ' ';
    std::cout << '\n';
}