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
/**
 * Patryk Kisielewski
 * 
 * Potyczki Algorytmiczne 2024
 * Zadanie: ZNA - Znaczki pocztowe [C]
*/
#include <unordered_map>
#include <vector>
#include <utility>
#include <cstdio>
#include <iostream>
#include <sstream>

using namespace std;

unordered_map<long long, int> map1;
vector<int> v;
int n;

int main() {

    std::ios::sync_with_stdio(false);

    cin >> n;

    v = vector<int>(n+1, 0);

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

    for (auto& item : map1) {
        ++v[item.second];
    }

    for (int i = n - 1; i > 0; --i) {
        v[i] += v[i+1];
    }

    cout << n << " ";

    for (int i = 2; i <= n; ++i) {
        int sum = 0;
        for (int j = i; j <= n; j += i) {
            sum += v[j];
        }
        cout << sum * i << " ";
    }

    cout << endl;

    return 0;
}