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

int main()
{
    int n;

    std::cin >> n;
    std::map<int, int> map;

    for (int i = 0; i < n; i++) {
        int input;
        std::cin >> input;
        map[input]++;
    }

    std::cout << n << " ";

    std::map<int, int>::iterator it;
    int i = 2;

    for (; i <= n; i++) {
        int result = 0;
        for (it = map.begin(); it != map.end(); it++) {
            result += (it->second / i) * i;
        }
        std::cout << result << " ";
        if (result == 0) break;
    }

    for (i++; i <= n; i++) {
        std::cout << 0 << " ";
    }
}