// // Mateusz Pietrowcow // #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define MOD 1000000007 #define INF 1000000000 #define INFL 1000000000000000000LL #define Tak cout << "TAK" << '\n' #define Nie cout << "NIE" << '\n' #define min3(x, y, z) min(x, min(y, z)) #define max3(x, y, z) max(x, max(y, z)) using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int,int> ii; typedef pair<long long, long long> pll; typedef pair<unsigned long long, unsigned long long> pull; vector<int> t, wstp; int n; void read() { cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; t.push_back(a); } } void solve() { sort(t.begin(), t.end()); int lic = 1; for (int i = 1; i < t.size(); i++) { if (t[i - 1] == t[i]) lic++; else { wstp.push_back(lic); lic = 1; } } wstp.push_back(lic); sort(wstp.begin(), wstp.end(), greater<int>()); for (int i = 1; i <= n; i++) { int wiel = i, last = wstp.size() - 1; int r = 0; while (wiel <= wstp.front()) { int low = 0, high = last, med; while (low != high) { med = (low + high - 1) / 2 + 1; if (wstp[med] >= wiel) low = med; else high = med - 1; } r += i * (low + 1); wiel += i; last = low; } cout << r << ' '; } } int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); read(); 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | // // Mateusz Pietrowcow // #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define MOD 1000000007 #define INF 1000000000 #define INFL 1000000000000000000LL #define Tak cout << "TAK" << '\n' #define Nie cout << "NIE" << '\n' #define min3(x, y, z) min(x, min(y, z)) #define max3(x, y, z) max(x, max(y, z)) using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int,int> ii; typedef pair<long long, long long> pll; typedef pair<unsigned long long, unsigned long long> pull; vector<int> t, wstp; int n; void read() { cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; t.push_back(a); } } void solve() { sort(t.begin(), t.end()); int lic = 1; for (int i = 1; i < t.size(); i++) { if (t[i - 1] == t[i]) lic++; else { wstp.push_back(lic); lic = 1; } } wstp.push_back(lic); sort(wstp.begin(), wstp.end(), greater<int>()); for (int i = 1; i <= n; i++) { int wiel = i, last = wstp.size() - 1; int r = 0; while (wiel <= wstp.front()) { int low = 0, high = last, med; while (low != high) { med = (low + high - 1) / 2 + 1; if (wstp[med] >= wiel) low = med; else high = med - 1; } r += i * (low + 1); wiel += i; last = low; } cout << r << ' '; } } int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); read(); solve(); } |