#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int n;
cin>>n;
map<int, int> mapa;
int a;
for(int i=0;i<n;i++) {
cin>>a;
mapa[a]++;
}
vector<int> vect;
for(auto a: mapa) vect.pb(a.se);
sort(vect.begin(), vect.end(), greater<int>());
for(int k=1;k<=n;k++) {
int ans=0;
for(auto a: vect) {
int add=a/k*k;
ans+=add;
if(add==0) break;
}
cout<<ans<<' ';
if(ans==0) {
k++;
while(k<=n) {
cout<<0<<' ';
k++;
}
}
}
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 | #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define fi first #define se second int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); int n; cin>>n; map<int, int> mapa; int a; for(int i=0;i<n;i++) { cin>>a; mapa[a]++; } vector<int> vect; for(auto a: mapa) vect.pb(a.se); sort(vect.begin(), vect.end(), greater<int>()); for(int k=1;k<=n;k++) { int ans=0; for(auto a: vect) { int add=a/k*k; ans+=add; if(add==0) break; } cout<<ans<<' '; if(ans==0) { k++; while(k<=n) { cout<<0<<' '; k++; } } } return 0; } |
English