#include <iostream> #include <algorithm> #include <vector> #include <map> #define P(a,n) for(int j=a;j<n;j++) #define P3(a,n,z) for(int z=a;z<n;z++) #define PD(pocz,kon,z) for(int z=pocz;z>=kon;z--) #define W while #define PB push_back #define F first #define S second #define ll long long #define O cout<< #define I cin>> #define endl '\n' #define E '\n' using namespace std; constexpr int MN=300'005; map<int,int>il; int sum[MN]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n,a; I n; P(0,n) { I a; il[a]++; } for(auto it:il) { int b=it.S; for(int d=1;d<=b;d++) { int tmp=it.S/d; tmp*=d; sum[d]+=tmp; } } P(1,n+1) O sum[j]<<' '; 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include <iostream> #include <algorithm> #include <vector> #include <map> #define P(a,n) for(int j=a;j<n;j++) #define P3(a,n,z) for(int z=a;z<n;z++) #define PD(pocz,kon,z) for(int z=pocz;z>=kon;z--) #define W while #define PB push_back #define F first #define S second #define ll long long #define O cout<< #define I cin>> #define endl '\n' #define E '\n' using namespace std; constexpr int MN=300'005; map<int,int>il; int sum[MN]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n,a; I n; P(0,n) { I a; il[a]++; } for(auto it:il) { int b=it.S; for(int d=1;d<=b;d++) { int tmp=it.S/d; tmp*=d; sum[d]+=tmp; } } P(1,n+1) O sum[j]<<' '; return 0; } |