from collections import Counter def zna(n, arr): stamp_count = Counter(arr) res = [n] for i in range(2, len(arr) + 1): k = sum((stamp_amount // i) * i for stamp_amount in stamp_count.values()) res.append(k) return ' '.join(map(str, res)) n = input() stamps = [int(x) for x in input().split()] print(zna(n, stamps))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from collections import Counter def zna(n, arr): stamp_count = Counter(arr) res = [n] for i in range(2, len(arr) + 1): k = sum((stamp_amount // i) * i for stamp_amount in stamp_count.values()) res.append(k) return ' '.join(map(str, res)) n = input() stamps = [int(x) for x in input().split()] print(zna(n, stamps)) |