def main(): n=int(input()) a=list(map(int,input().split())) a.sort() b=0 g=0 h=[] for i in a: if i==b: g+=1 else: h.append(g) g=1 b=i h.append(g) #print(h) k=[0 for i in range(n+1)] for i in h: g=1 while g<=i: k[g]+=i//g g+=1 for i in range(1,n+1): print(k[i]*i,end=' ') main()
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 | def main(): n=int(input()) a=list(map(int,input().split())) a.sort() b=0 g=0 h=[] for i in a: if i==b: g+=1 else: h.append(g) g=1 b=i h.append(g) #print(h) k=[0 for i in range(n+1)] for i in h: g=1 while g<=i: k[g]+=i//g g+=1 for i in range(1,n+1): print(k[i]*i,end=' ') main() |