#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int wyn[300009];
int main()
{
cin.tie(0)->sync_with_stdio(0);
map<int,int>ma;
vector<int>m; int mx=0;
int n; cin>>n;
for(int i=0;i<n;i++){
int x; cin>>x; ma[x]++;
}
for(auto i:ma){
m.push_back(i.second);
mx=max(mx,i.second);
}
sort(m.begin(), m.end(), greater());
for(int k=2;k<=n;k++)
{
if(k>mx) break;
int sum=0;
for(auto i:m){
int tt=(i/k);
tt*=k;
sum+=tt;
if(tt==0) break;
}
wyn[k]=sum;
}
wyn[1]=n;
for(int i=1;i<=n;i++) cout<<wyn[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 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <map> #include <iostream> #include <vector> #include <algorithm> using namespace std; int wyn[300009]; int main() { cin.tie(0)->sync_with_stdio(0); map<int,int>ma; vector<int>m; int mx=0; int n; cin>>n; for(int i=0;i<n;i++){ int x; cin>>x; ma[x]++; } for(auto i:ma){ m.push_back(i.second); mx=max(mx,i.second); } sort(m.begin(), m.end(), greater()); for(int k=2;k<=n;k++) { if(k>mx) break; int sum=0; for(auto i:m){ int tt=(i/k); tt*=k; sum+=tt; if(tt==0) break; } wyn[k]=sum; } wyn[1]=n; for(int i=1;i<=n;i++) cout<<wyn[i]<<' '; } |
English