#include<iostream> #include<algorithm> #include<map> using namespace std; int main(){ ios::sync_with_stdio(0); map<int, int> mapa; int n, znaczek, s; cin >> n; for(int i = 0; i < n; i++){ cin >> znaczek; mapa[znaczek]++; } cout << n << " "; for(int i = 2; i <= n; i++){ s=0; for( auto it = mapa.cbegin(); it != mapa.cend(); ++it ) if(i <= it->second) s+=it->second % i; else s+= it->second; cout << n - s << " "; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include<iostream> #include<algorithm> #include<map> using namespace std; int main(){ ios::sync_with_stdio(0); map<int, int> mapa; int n, znaczek, s; cin >> n; for(int i = 0; i < n; i++){ cin >> znaczek; mapa[znaczek]++; } cout << n << " "; for(int i = 2; i <= n; i++){ s=0; for( auto it = mapa.cbegin(); it != mapa.cend(); ++it ) if(i <= it->second) s+=it->second % i; else s+= it->second; cout << n - s << " "; } } |