// #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> // #include <x86intrin.h> using namespace std; #if __cplusplus >= 202002L using namespace numbers; #endif int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n; cin >> n; map<int, int> cnt; for(auto i = 0; i < n; ++ i){ int x; cin >> x; ++ cnt[x]; } vector<int> ccnt(n + 1); for(auto [_, c]: cnt){ ++ ccnt[c]; } vector<array<int, 2>> cnt_ccnt; for(auto c = 1; c <= n; ++ c){ if(ccnt[c] > 0){ cnt_ccnt.push_back({c, ccnt[c]}); } } for(auto k = 1; k <= n; ++ k){ int res = 0; for(auto [c, cc]: cnt_ccnt){ res += c / k * k * cc; } cout << res << " "; } cout << "\n"; return 0; } /* */
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 | // #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> // #include <x86intrin.h> using namespace std; #if __cplusplus >= 202002L using namespace numbers; #endif int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n; cin >> n; map<int, int> cnt; for(auto i = 0; i < n; ++ i){ int x; cin >> x; ++ cnt[x]; } vector<int> ccnt(n + 1); for(auto [_, c]: cnt){ ++ ccnt[c]; } vector<array<int, 2>> cnt_ccnt; for(auto c = 1; c <= n; ++ c){ if(ccnt[c] > 0){ cnt_ccnt.push_back({c, ccnt[c]}); } } for(auto k = 1; k <= n; ++ k){ int res = 0; for(auto [c, cc]: cnt_ccnt){ res += c / k * k * cc; } cout << res << " "; } cout << "\n"; return 0; } /* */ |