#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
map<int, int> m;
for(int i = 0; i < n; i++)
{
int tmp;
cin >> tmp;
m[tmp]++;
}
cout << n;
int i = 1;
while(i < n)
{
int ans = 0;
for(std::map<int, int>::iterator it = m.begin(); it != m.end(); ++it)
{
ans += it->second/(i+1);
}
cout << " " << ans*(i+1) ;
i++;
if(ans == 0)break;
}
while(i < n){cout << " " << "0"; i++;}
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 | #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> m; for(int i = 0; i < n; i++) { int tmp; cin >> tmp; m[tmp]++; } cout << n; int i = 1; while(i < n) { int ans = 0; for(std::map<int, int>::iterator it = m.begin(); it != m.end(); ++it) { ans += it->second/(i+1); } cout << " " << ans*(i+1) ; i++; if(ans == 0)break; } while(i < n){cout << " " << "0"; i++;} return 0; } |
English