#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define ld long double #define ull unsigned long long void dbg_out() { cout << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) void solve() { ll n; cin >> n; ll tmp; map<ll, ll> mp; vector<ll> res(n, 0); for(ll i = 0; i < n; i++){ cin >> tmp; mp[tmp]++; } for(auto el : mp){ for(ll i = 1; i <= el.second; i++){ res[i-1] += el.second - (el.second % i); } } for(auto el : res) cout << el << " "; cout << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("../../in.in", "r", stdin); // freopen("../../out.out", "w", stdout); // #endif 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 | #include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define ld long double #define ull unsigned long long void dbg_out() { cout << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) void solve() { ll n; cin >> n; ll tmp; map<ll, ll> mp; vector<ll> res(n, 0); for(ll i = 0; i < n; i++){ cin >> tmp; mp[tmp]++; } for(auto el : mp){ for(ll i = 1; i <= el.second; i++){ res[i-1] += el.second - (el.second % i); } } for(auto el : res) cout << el << " "; cout << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("../../in.in", "r", stdin); // freopen("../../out.out", "w", stdout); // #endif solve(); } |