import math from collections import defaultdict # 3 4 2 def computeNumber(city, persons): return math.floor(city / persons) * persons cityNo = int(input()) items = list(map(int, input().split())) dict = defaultdict(int) for i in range(len(items)): dict[items[i]] += 1 allValues = list(dict.values()) result = [] for i in range(1, cityNo + 1): temp = 0 for value in allValues: temp += computeNumber(value , i) result.append(temp) print(*result)
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 | import math from collections import defaultdict # 3 4 2 def computeNumber(city, persons): return math.floor(city / persons) * persons cityNo = int(input()) items = list(map(int, input().split())) dict = defaultdict(int) for i in range(len(items)): dict[items[i]] += 1 allValues = list(dict.values()) result = [] for i in range(1, cityNo + 1): temp = 0 for value in allValues: temp += computeNumber(value , i) result.append(temp) print(*result) |