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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <map>


static const int MAX_TOTAL_CNT = (int) 3e5;

static const int MAX_AGGREGATE_CNT = 777;


struct Aggregate
{
    int iSingleGroupSize;   // number of stamps in a group
    int iGroupCnt;          // number of such groups (cities)
};


static int iTotalCnt, iGoodCounts, iAggregates;


static std::unordered_map<int, int> mCountsForCities;  // key: city ID; value: number of stamps from this city


static Aggregate aAggregates[MAX_AGGREGATE_CNT];

static int aGoodCounts[MAX_TOTAL_CNT / 2];       // 0 based index

static int aAnswers[MAX_TOTAL_CNT + 2] = { };    // 1 based index


static void ReadData()
{
    int k;

    std::cin >> iTotalCnt;

    for (int i = 0; i < iTotalCnt; ++i)
    {
        std::cin >> k;

        mCountsForCities[k]++;
    }
}


static void WriteAnswer()
{
    std::cout << iTotalCnt;

    for (int i = 2; i <= iTotalCnt; ++i)
    {
        std::cout << " ";
        std::cout << aAnswers[i];
    }
}


static void GatherGoodCounts()
{
    int * pDst = aGoodCounts;

    iGoodCounts = 0;

    for (auto pSrc = mCountsForCities.begin(); pSrc != mCountsForCities.end(); ++pSrc)
    {
        int iCnt = pSrc->second;

        if (iCnt > 1)
        {
            *pDst++ = iCnt;
            iGoodCounts++;
        }
    }
}


static void AggregateGoodCounts()
{
    std::map<int, int, std::greater<int>> mAggregates;  // key: number of stamps in a group; value: number of such groups (cities)

    for (int i = 0; i < iGoodCounts; ++i)
    {
        int iGroupSize = aGoodCounts[i];

        mAggregates[iGroupSize]++;
    }

    iAggregates = 0;

    for (auto pSrc = mAggregates.begin(); pSrc != mAggregates.end(); ++pSrc)
    {
        Aggregate & ag = aAggregates[iAggregates++];

        ag.iSingleGroupSize = pSrc->first;
        ag.iGroupCnt = pSrc->second;
    }
}


static void Init()
{
    GatherGoodCounts();
    AggregateGoodCounts();
}


static int GetCountForPersons(int iPersons)
{
    int iCnt = 0;

    for (int i = 0; i < iAggregates; ++i)
    {
        Aggregate & ag = aAggregates[i];

        if (ag.iSingleGroupSize < iPersons)
            break;

        int k = ag.iSingleGroupSize - (ag.iSingleGroupSize % iPersons);

        k *= ag.iGroupCnt;

        iCnt += k;
    }

    return iCnt;
}


static void Solve()
{
    if (iAggregates == 0)
        return;

    int iMaxPersons = aAggregates[0].iSingleGroupSize;

    for (int iPersons = iMaxPersons; iPersons >= 2; --iPersons)
    {
        aAnswers[iPersons] = GetCountForPersons(iPersons);
    }
}


static void OneCase()
{
    ReadData();
    Init();
    Solve();
    WriteAnswer();
}


int main()
{
    OneCase();
}