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

int main() {
    std::ios_base::sync_with_stdio(false);
	int n;
	std::cin >> n;
	std::map<int, int> mp;
	for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        mp[x]++;
    }

    int divs[n+1];
    divs[1] = n;
    for(int i = 2; i <= n; i++) {
    	divs[i]=0;
    	std::map<int, int>::iterator it = mp.begin();
    	while (it != mp.end()) {
                divs[i] += i * (it->second / i);
                ++it;
        }
    }

    for(int i = 1; i <= n; i++) {
    	std::cout << divs[i] << " ";
    }

	return 0;
}