#include <iostream>                                                             
#include <algorithm>  
int compare(const void* a, const void* b)
{
	const long* x = (long*) a;
	const long* y = (long*) b;
	if (*x > *y)
		return 1;
	else if (*x < *y)
		return -1;
	return 0;
}
int compare_odwr(const void* a, const void* b)
{
	const long* x = (long*) a;
	const long* y = (long*) b;
	if (*x < *y)
		return 1;
	else if (*x > *y)
		return -1;
	return 0;
}
int main()                                                                      
{   
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
    long ile_znaczkow;   
    long i, k;
    long tab[300000];
    long tab_wystapien[300000];
    long ile_odda_k[300001]={};
    
    std::cin >> ile_znaczkow;                                                      
    for (i=0; i<ile_znaczkow; ++i)
    {
        std::cin >> tab[i];                                                    
    }
    
    std::qsort(tab, ile_znaczkow, sizeof(long), compare);
    
    long poprzedni = tab[0];
    long ile_wystapien=0;
    long ktory=0;
    for(i=0; i<ile_znaczkow; ++i)
    {
        if(tab[i]==poprzedni)
            ++ile_wystapien;
        else 
        {
            tab_wystapien[ktory++]=ile_wystapien;
            poprzedni = tab[i];
            ile_wystapien=1;
        }
    }
    tab_wystapien[ktory++]=ile_wystapien;
    ile_wystapien = ktory;
    
    std::qsort(tab_wystapien, ile_wystapien, sizeof(long), compare_odwr);
    for(k=1;k<ile_znaczkow+1; ++k)
    {
        for (i=0; i<ile_wystapien; ++i)
        {
            if(tab_wystapien[i]==tab_wystapien[i]%k)
                break;
            else
                ile_odda_k[k] += tab_wystapien[i]-tab_wystapien[i]%k;
        }
    }
    for (i=1; i<ile_znaczkow+1; ++i)
    {
        std::cout << ile_odda_k[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 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  | #include <iostream> #include <algorithm> int compare(const void* a, const void* b) { const long* x = (long*) a; const long* y = (long*) b; if (*x > *y) return 1; else if (*x < *y) return -1; return 0; } int compare_odwr(const void* a, const void* b) { const long* x = (long*) a; const long* y = (long*) b; if (*x < *y) return 1; else if (*x > *y) return -1; return 0; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); long ile_znaczkow; long i, k; long tab[300000]; long tab_wystapien[300000]; long ile_odda_k[300001]={}; std::cin >> ile_znaczkow; for (i=0; i<ile_znaczkow; ++i) { std::cin >> tab[i]; } std::qsort(tab, ile_znaczkow, sizeof(long), compare); long poprzedni = tab[0]; long ile_wystapien=0; long ktory=0; for(i=0; i<ile_znaczkow; ++i) { if(tab[i]==poprzedni) ++ile_wystapien; else { tab_wystapien[ktory++]=ile_wystapien; poprzedni = tab[i]; ile_wystapien=1; } } tab_wystapien[ktory++]=ile_wystapien; ile_wystapien = ktory; std::qsort(tab_wystapien, ile_wystapien, sizeof(long), compare_odwr); for(k=1;k<ile_znaczkow+1; ++k) { for (i=0; i<ile_wystapien; ++i) { if(tab_wystapien[i]==tab_wystapien[i]%k) break; else ile_odda_k[k] += tab_wystapien[i]-tab_wystapien[i]%k; } } for (i=1; i<ile_znaczkow+1; ++i) { std::cout << ile_odda_k[i] << " "; } return 0; }  | 
            
        
                    English