#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define fi first #define se second constexpr int MAX_N=3e5+14; int N, rres[MAX_N]; map<int,int> qt; void Input(){ int a; cin>>N; FOR(i,0,N-1) cin>>a, ++qt[a]; } void Solve(){ for(auto it=qt.begin(); it!=qt.end(); ++it){ FOR(i,1,it->se){ rres[i]+=it->se-(it->se%i); } } FOR(i,1,N) cout<<rres[i]<<" "; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); Input(); Solve(); }
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; #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define fi first #define se second constexpr int MAX_N=3e5+14; int N, rres[MAX_N]; map<int,int> qt; void Input(){ int a; cin>>N; FOR(i,0,N-1) cin>>a, ++qt[a]; } void Solve(){ for(auto it=qt.begin(); it!=qt.end(); ++it){ FOR(i,1,it->se){ rres[i]+=it->se-(it->se%i); } } FOR(i,1,N) cout<<rres[i]<<" "; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); Input(); Solve(); } |