#include <bits/stdc++.h> using namespace std; const int maxn = 3e5+1; map <int, int> mp; vector <int> res(maxn); int readInt () { bool minus = false; int result = 0; char ch; ch = getchar(); while (true) { if (ch == '-') break; if (ch >= '0' && ch <= '9') break; ch = getchar(); } if (ch == '-') minus = true; else result = ch-'0'; while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; result = result*10 + (ch - '0'); } if (minus) return -result; else return result; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n = readInt(); res.resize(n+7); for (int i = 0; i < n; i++) { int a = readInt(); mp[a]++; } // map<int, int>::iterator it2 = mp.begin(); // // while (it2 != mp.end()) { // cout << it2->first << ": " << it2->second << endl; // ++it2; // } // map<int, int>::iterator it = mp.begin(); while (it != mp.end()) { for (int i = 1; i <= it->second; i++) { res[i] += (it->second - (it->second%i)); } it++; } for (int k = 1; k <= n; k++) cout << res[k] << ' '; //cout << endl; }
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 49 50 51 52 53 54 55 56 57 58 | #include <bits/stdc++.h> using namespace std; const int maxn = 3e5+1; map <int, int> mp; vector <int> res(maxn); int readInt () { bool minus = false; int result = 0; char ch; ch = getchar(); while (true) { if (ch == '-') break; if (ch >= '0' && ch <= '9') break; ch = getchar(); } if (ch == '-') minus = true; else result = ch-'0'; while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; result = result*10 + (ch - '0'); } if (minus) return -result; else return result; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n = readInt(); res.resize(n+7); for (int i = 0; i < n; i++) { int a = readInt(); mp[a]++; } // map<int, int>::iterator it2 = mp.begin(); // // while (it2 != mp.end()) { // cout << it2->first << ": " << it2->second << endl; // ++it2; // } // map<int, int>::iterator it = mp.begin(); while (it != mp.end()) { for (int i = 1; i <= it->second; i++) { res[i] += (it->second - (it->second%i)); } it++; } for (int k = 1; k <= n; k++) cout << res[k] << ' '; //cout << endl; } |