Manasa and Stones
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Caso de ejemplo — tu programa lee de stdin e imprime en stdout.
Start at stone 0. Place n stones. Each stone = previous + a OR previous + b. Find all possible values for the last (n-th) stone, sorted ascending.
Formula: If we use 'a' j times and 'b' (n-1-j) times, last stone = j×a + (n-1-j)×b. Try all j from 0 to n-1.
Example: n=3, a=1, b=2 → j=0: 0+2+2=4, j=1: 0+1+2=3 or 0+2+1=3, j=2: 0+1+1=2 → Unique: [2,3,4]
Formato de entrada
First line: t (test cases). Next t lines: each line has n a b (space-separated).
Formato de salida
For each test case, output the possible last stone values, space-separated, in ascending order.
Restricciones
1 ≤ t ≤ 10, 1 ≤ n, a, b ≤ 10³