#include <cstdio> #include <map> using namespace std; int n, i, a; map<int, int> s; int t[300001]; int main() { scanf("%d", &n); for (i = 1; i <= n; i++) { t[i] = 0; scanf("%d", &a); if (s.find(a) != s.end()) { s[a] = s[a] + 1; } else { s[a] = 1; } } for (map<int, int>::iterator it = s.begin(); it != s.end(); it++) { for (i = 1; i <= it->second; i++) { t[i] += it->second - it->second % i; } } printf("%d", t[1]); for (i = 2; i <= n; i++) { printf(" %d", t[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 33 34 35 36 37 38 | #include <cstdio> #include <map> using namespace std; int n, i, a; map<int, int> s; int t[300001]; int main() { scanf("%d", &n); for (i = 1; i <= n; i++) { t[i] = 0; scanf("%d", &a); if (s.find(a) != s.end()) { s[a] = s[a] + 1; } else { s[a] = 1; } } for (map<int, int>::iterator it = s.begin(); it != s.end(); it++) { for (i = 1; i <= it->second; i++) { t[i] += it->second - it->second % i; } } printf("%d", t[1]); for (i = 2; i <= n; i++) { printf(" %d", t[i]); } printf("\n"); return 0; } |