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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Created by piotr on 11.03.2024.
//
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <vector>

struct Count {
  int value;
  int count;
};

std::vector <Count> generate_counts(std::vector<int>& values)
{
	std::sort(values.begin(), values.end());

	std::vector <Count> counts;
	counts.reserve(values.size());

	for (int value : values) {
		if (!counts.empty() && value==counts.back().value) {
			counts.back().count++;
		}
		else {
			counts.push_back({value, 1});
		}
	}
	return counts;
}

std::vector <int> extract_counts(const std::vector<Count>& counts)
{
	std::vector<int> values(counts.size());
	std::transform(counts.begin(), counts.end(), values.begin(), [](Count c) { return c.count; });
	return values;
}

int main()
{
	int N;
	std::vector<int> numbers;
	assert(scanf("%d", &N)==1);
	numbers.resize(N);
	for (int& number : numbers) {
		assert(scanf("%d", &number)==1);
	}

	std::vector<Count> foo = generate_counts(numbers);
	std::vector<int> bar = extract_counts(foo);
	std::vector<Count> counts = generate_counts(bar);

	std::vector<int> results(N, 0);
	results[0] = N;

	int sum_prev_counts = 0;
	std::vector<Count>::const_iterator first_count_to_consider = counts.begin();

	for (int n = 2; n<=N && first_count_to_consider!=counts.end(); ++n) {
		int stamps_left = sum_prev_counts;
		for (auto it = first_count_to_consider; it!=counts.end(); ++it) {
			stamps_left += (it->value % n) * it->count;
		}
		results[n-1] = N - stamps_left;

		if (first_count_to_consider->value == n) {
			sum_prev_counts += first_count_to_consider->value * first_count_to_consider->count;
			++first_count_to_consider;
		}
	}

	printf("%d", results[0]);
	for (int i = 1; i<N; ++i) {
		printf(" %d", results[i]);
	}
	putchar('\n');
}