#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
map<int,int> ile;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp;
ile[tmp]++;
}
// skompresuj liczby wystapien
map<int,int> ile2;
for (pair<int,int> x : ile)
ile2[x.s]++;
int wszystkich = n;
for (int k = 1; k <= n; k++) {
if (ile2.empty()) {
cout << "0 ";
continue;
}
while (!ile2.empty() and k > ile2.begin()->f) {
wszystkich -= ile2.begin()->f * ile2.begin()->s;
ile2.erase(ile2.begin());
}
int wyn = wszystkich;
for (pair<int,int> x : ile2)
wyn -= x.s * (x.f % k);
cout << wyn << ' ';
}
cout << '\n';
return 0;
}
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 | #include <bits/stdc++.h> using namespace std; #define f first #define s second int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; map<int,int> ile; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; ile[tmp]++; } // skompresuj liczby wystapien map<int,int> ile2; for (pair<int,int> x : ile) ile2[x.s]++; int wszystkich = n; for (int k = 1; k <= n; k++) { if (ile2.empty()) { cout << "0 "; continue; } while (!ile2.empty() and k > ile2.begin()->f) { wszystkich -= ile2.begin()->f * ile2.begin()->s; ile2.erase(ile2.begin()); } int wyn = wszystkich; for (pair<int,int> x : ile2) wyn -= x.s * (x.f % k); cout << wyn << ' '; } cout << '\n'; return 0; } |
English