#include <cstdio> #include <map> using namespace std; typedef map<int,int> iimap; int main() { int n,N,k,S; iimap C; scanf("%d",&N); for (n = 0; n < N; n++) { scanf("%d",&k); C[k]++; } /* for (iimap::iterator i = C.begin(); i != C.end(); ++i) { printf("%d %d\n",i->first,i->second); } */ for (k = 1; k <= N; k++) { S = 0; for (iimap::iterator i = C.begin(); i != C.end(); ++i) { S += ((int) C[i->first] / k) * k; } printf("%d ",S); } 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 | #include <cstdio> #include <map> using namespace std; typedef map<int,int> iimap; int main() { int n,N,k,S; iimap C; scanf("%d",&N); for (n = 0; n < N; n++) { scanf("%d",&k); C[k]++; } /* for (iimap::iterator i = C.begin(); i != C.end(); ++i) { printf("%d %d\n",i->first,i->second); } */ for (k = 1; k <= N; k++) { S = 0; for (iimap::iterator i = C.begin(); i != C.end(); ++i) { S += ((int) C[i->first] / k) * k; } printf("%d ",S); } return 0; } |