#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair <int, int>; using pll = pair <ll, ll>; const int inf = 1e9+7; const ll inf_ll = 1e18+7; void boost () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, a, res[300007]; map <int, int> m; int main () { boost(); cin >> n; for (int i = 0; i < n; i++) { cin >> a; m[a] = m[a] + 1; } for (auto &p: m) { int x = p.second; for (int i = 1; i <= x; i++) { int y = x % i; res[i] += x - y; } } for (int i = 1; i <= n; i++) { cout << res[i] << " "; } 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 | #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair <int, int>; using pll = pair <ll, ll>; const int inf = 1e9+7; const ll inf_ll = 1e18+7; void boost () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, a, res[300007]; map <int, int> m; int main () { boost(); cin >> n; for (int i = 0; i < n; i++) { cin >> a; m[a] = m[a] + 1; } for (auto &p: m) { int x = p.second; for (int i = 1; i <= x; i++) { int y = x % i; res[i] += x - y; } } for (int i = 1; i <= n; i++) { cout << res[i] << " "; } cout << "\n"; return 0; } |