def solve(): n=int(input()) inp = [eval(i) for i in input().split()] d={} for el in inp: if el in d: d[el]+=1 else: d[el]=1 d=sorted(d.values(), reverse=True) print(n,end=" ") koniec=0 for i in range(2,n+1): sum=0 for el in d: tmp=el//i if tmp==0: break else: sum+=tmp*i if sum==0: print(sum,end=" ") koniec=n-i break print(sum,end=" ") for _ in range(koniec): print(0,end=" ") solve()
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 | def solve(): n=int(input()) inp = [eval(i) for i in input().split()] d={} for el in inp: if el in d: d[el]+=1 else: d[el]=1 d=sorted(d.values(), reverse=True) print(n,end=" ") koniec=0 for i in range(2,n+1): sum=0 for el in d: tmp=el//i if tmp==0: break else: sum+=tmp*i if sum==0: print(sum,end=" ") koniec=n-i break print(sum,end=" ") for _ in range(koniec): print(0,end=" ") solve() |