#include <bits/stdc++.h>
using namespace std;
vector <int> v,s,t;
int a,n,m,o;
//int t[100009];
int main(){
cin.tie(0);
ios_base::sync_with_stdio(false);
cout.tie(0);
cin>>n;
for(int i=0; i<n; i++){
cin>>a;
t.push_back(a);
}
sort(t.begin(), t.end());
int h=1;
for(int i=1; i<n; i++){
if(t[i]==t[i-1])h++;
else{
//cout<<h<<" "<<i<<'\n';
v.push_back(h);
h=1;
}
}
v.push_back(h);
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
m=v.size();
for(int i=1; i<=n; i++){
int w=0;
o=m;
for(int j=0; j<m;j++){
w+=v[j]- v[j]%i;
//cout<<w<<" ";
if(j!=0){
if(v[j]<=i && v[j-1]>i)o=j;
}
}
m=o;
cout<<w<<" ";
//cout<<'\n';
}
}
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 | #include <bits/stdc++.h> using namespace std; vector <int> v,s,t; int a,n,m,o; //int t[100009]; int main(){ cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0); cin>>n; for(int i=0; i<n; i++){ cin>>a; t.push_back(a); } sort(t.begin(), t.end()); int h=1; for(int i=1; i<n; i++){ if(t[i]==t[i-1])h++; else{ //cout<<h<<" "<<i<<'\n'; v.push_back(h); h=1; } } v.push_back(h); sort(v.begin(), v.end()); reverse(v.begin(), v.end()); m=v.size(); for(int i=1; i<=n; i++){ int w=0; o=m; for(int j=0; j<m;j++){ w+=v[j]- v[j]%i; //cout<<w<<" "; if(j!=0){ if(v[j]<=i && v[j-1]>i)o=j; } } m=o; cout<<w<<" "; //cout<<'\n'; } } |
English