#include <cstdio> #include <map> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define VAR(v,w) __typeof(w) v=(w) #define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it) #define SD second #define INT(x) int x; scanf("%d", &x) typedef long long LL; LL r[300001]; int main() { INT(n); map<int, int> m; REP(i,n) { INT(a); ++m[a]; } FORE(it,m) FOR(i,1,it->SD+1) r[i] += it->SD - it->SD % i; REP(i,n) { if (i) printf(" "); printf("%lld", r[i + 1]); } printf("\n"); }
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 | #include <cstdio> #include <map> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define VAR(v,w) __typeof(w) v=(w) #define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it) #define SD second #define INT(x) int x; scanf("%d", &x) typedef long long LL; LL r[300001]; int main() { INT(n); map<int, int> m; REP(i,n) { INT(a); ++m[a]; } FORE(it,m) FOR(i,1,it->SD+1) r[i] += it->SD - it->SD % i; REP(i,n) { if (i) printf(" "); printf("%lld", r[i + 1]); } printf("\n"); } |