#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie();
cout.tie();
int n;cin>>n;
map<int,int> mp;
vector<int> vec(n,0);
for(int i=0;i<n;i++){
int x;
cin>>x;
if(!mp.count(x)){
mp[x]=i;
}
vec[mp[x]]++;
}
sort(vec.begin(),vec.end());
auto it=vec.begin();
for(int i=1;i<=n;i++){
int S=0;
while(it!=vec.end() and *it<i)it++;
auto jt=it;
while(jt!=vec.end()){S+=*jt-*jt%i;jt++;}
cout<<S<<" ";
}
}
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 | #include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); int n;cin>>n; map<int,int> mp; vector<int> vec(n,0); for(int i=0;i<n;i++){ int x; cin>>x; if(!mp.count(x)){ mp[x]=i; } vec[mp[x]]++; } sort(vec.begin(),vec.end()); auto it=vec.begin(); for(int i=1;i<=n;i++){ int S=0; while(it!=vec.end() and *it<i)it++; auto jt=it; while(jt!=vec.end()){S+=*jt-*jt%i;jt++;} cout<<S<<" "; } } |
English