#K70432. Dice Roll Sums
Dice Roll Sums
Dice Roll Sums
Given an n-sided die, roll it k times. Compute all unique possible sums of the outcomes, and output these sums in ascending order. The possible sums can be expressed mathematically as:
$$S = \{ s \mid s = x_1+x_2+\cdots+x_k, \; x_i \in \{1,2,\dots,n\} \}$$
Your task is to implement an efficient solution that computes these sums.
inputFormat
The input consists of a single line containing two space-separated integers: n (the number of faces on the die) and k (the number of times the die is rolled).
outputFormat
Output all unique possible sums in ascending order. Each sum should be printed on its own line.## sample
4 2
2
3
4
5
6
7
8
</p>