#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 3e5+10; void fs(int &number) { register int c; number = 0; c = getchar(); for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; } int c[N]; void solve() { int n; fs(n); map<int, int> cnt; for (int i=1; i<=n; ++i) { int a; fs(a); ++cnt[a]; } vector<int> v; for (auto u : cnt) ++c[u.second], v.push_back(u.second); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); for (int k=1; k<=n; ++k) { int s=0; for (auto u : v) s+=c[u]*(u%k); printf("%d ", n-s); } } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int t=1; //cin>>t; while (t--) 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 3e5+10; void fs(int &number) { register int c; number = 0; c = getchar(); for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; } int c[N]; void solve() { int n; fs(n); map<int, int> cnt; for (int i=1; i<=n; ++i) { int a; fs(a); ++cnt[a]; } vector<int> v; for (auto u : cnt) ++c[u.second], v.push_back(u.second); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); for (int k=1; k<=n; ++k) { int s=0; for (auto u : v) s+=c[u]*(u%k); printf("%d ", n-s); } } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int t=1; //cin>>t; while (t--) solve(); } |