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

using namespace std;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(0);

    int input_size; cin >> input_size;
    vector<int> input;

    int temp;
    for(int i = 0; i < input_size; i ++){
        cin >> temp; input.push_back(temp);
    }

    sort(input.begin(), input.end());

    vector<int> result(input_size + 1, 0);

    int how_many = 0, last = -1;

    for(int i = 0; i < input_size; i ++){
        if(input[i] != last){
            for(int j = 1; j <= how_many; j ++){
                result[j] += (how_many - (how_many % j));
            }

            how_many = 1;
        } else {
            how_many ++;
        }

        last = input[i];
    }

    for(int j = 1; j <= how_many; j ++){
        result[j] += (how_many - (how_many % j));
    }

    for(int i = 1; i <= input_size; i ++){
        cout << result[i] << " ";
    }

    return 0;
}