n = int(input()) cities = [int(i) for i in input().split(' ')] repeats = [] result = [] for city in list(dict.fromkeys(cities)): count = cities.count(city) repeats.append(count) for i in range (n): sum = 0 for repeat in repeats: sum += (i + 1) * int(repeat / (i + 1)) result.append(sum) repeats = [x for x in repeats if x > i] print(*result)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | n = int(input()) cities = [int(i) for i in input().split(' ')] repeats = [] result = [] for city in list(dict.fromkeys(cities)): count = cities.count(city) repeats.append(count) for i in range (n): sum = 0 for repeat in repeats: sum += (i + 1) * int(repeat / (i + 1)) result.append(sum) repeats = [x for x in repeats if x > i] print(*result) |