#include<cstdio> #include<algorithm> #include<map> #define S 300007 using namespace std; map<int,int> M; int ans[S]; int main(void){ int n; scanf("%d", &n); for(int i = 1; i <= n; i++){ int x; scanf("%d", &x); M[x]++; } for(auto &x: M){ for(int i = 1; i <= x.second; i++){ int p = x.second - x.second%i; ans[i] += p; } } for(int i = 1; i <= n; i++){ printf("%d ", ans[i]); } printf("\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 | #include<cstdio> #include<algorithm> #include<map> #define S 300007 using namespace std; map<int,int> M; int ans[S]; int main(void){ int n; scanf("%d", &n); for(int i = 1; i <= n; i++){ int x; scanf("%d", &x); M[x]++; } for(auto &x: M){ for(int i = 1; i <= x.second; i++){ int p = x.second - x.second%i; ans[i] += p; } } for(int i = 1; i <= n; i++){ printf("%d ", ans[i]); } printf("\n"); return 0; } |