#include<bits/stdc++.h>
using namespace std;
constexpr int MAXN = 3e5+2;
unordered_map<int, int> ile;
int odp[MAXN];
int main() {
int n;
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; ++i) {
int x;
cin >> x;
ile[x]++;
}
vector<int> h;
for(auto &[k, v] : ile) {
int dziel = 1;
while(v/dziel) {
odp[dziel] += v/dziel;
dziel++;
}
}
for(int i = 1; i <= n; ++i) cout << odp[i]*i << ' ';
}
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 | #include<bits/stdc++.h> using namespace std; constexpr int MAXN = 3e5+2; unordered_map<int, int> ile; int odp[MAXN]; int main() { int n; ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0; i < n; ++i) { int x; cin >> x; ile[x]++; } vector<int> h; for(auto &[k, v] : ile) { int dziel = 1; while(v/dziel) { odp[dziel] += v/dziel; dziel++; } } for(int i = 1; i <= n; ++i) cout << odp[i]*i << ' '; } |
English