from collections import Counter def main(): n = int(input()) nums = [int(i) for i in input().split()] counter = Counter(nums) results = (n + 1) * [0] for val in counter.values(): for i in range(1, val + 1): results[i] += val - (val % i) for i in range(1, n + 1): if i == n: print(results[i]) else: print(results[i], end=" ") if __name__ == "__main__": main()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from collections import Counter def main(): n = int(input()) nums = [int(i) for i in input().split()] counter = Counter(nums) results = (n + 1) * [0] for val in counter.values(): for i in range(1, val + 1): results[i] += val - (val % i) for i in range(1, n + 1): if i == n: print(results[i]) else: print(results[i], end=" ") if __name__ == "__main__": main() |