import math n = int(input()) sequence = [int(i) for i in input().split(" ")] count_array = {} response_array = [0] * n response_array[0] = n for city in sequence: if city not in count_array: count_array[city] = 1 else: count_array[city] += 1 count_array = dict(sorted(count_array.items(), key=lambda x:x[1], reverse=True)) for x in range(2,n+1): if x>next(iter(count_array.values())): for y in range (x,n+1): response_array[y-1] = 0 break result = 0 for city_result in count_array.values(): result += math.floor(city_result / x )*x response_array[x-1] = result print(" ".join(str(x) for x in response_array))
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 | import math n = int(input()) sequence = [int(i) for i in input().split(" ")] count_array = {} response_array = [0] * n response_array[0] = n for city in sequence: if city not in count_array: count_array[city] = 1 else: count_array[city] += 1 count_array = dict(sorted(count_array.items(), key=lambda x:x[1], reverse=True)) for x in range(2,n+1): if x>next(iter(count_array.values())): for y in range (x,n+1): response_array[y-1] = 0 break result = 0 for city_result in count_array.values(): result += math.floor(city_result / x )*x response_array[x-1] = result print(" ".join(str(x) for x in response_array)) |