#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int N;
cin >> N;
map<int,int> freq;
for(int i = 0; i < N; i++){
int x;
cin >> x;
freq[x]++;
}
vector<int> ans(N+1);
for(auto [x, f] : freq){
for(int i = 1; i <= f; i++){
ans[i] += f - (f % i);
}
}
for(int i = 1; i <= N; i++){
cout << ans[i] << " \n"[i == N];
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false), cin.tie(nullptr); int N; cin >> N; map<int,int> freq; for(int i = 0; i < N; i++){ int x; cin >> x; freq[x]++; } vector<int> ans(N+1); for(auto [x, f] : freq){ for(int i = 1; i <= f; i++){ ans[i] += f - (f % i); } } for(int i = 1; i <= N; i++){ cout << ans[i] << " \n"[i == N]; } } |
English