Write a program that, given a natural number and natural numbers , prints all the subsets (maybe with repeated numbers, but using every at most once) whose sum is exactly .
Input consists of a natural number , followed by a number , followed by .
Print all the subsets whose sum is that can be made up with .
You can print in any order both the solutions and the elements inside each solution.
For this exercise, a very simple algorithm can be too slow.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T09:59:01.965Z
© Jutge.org, 2006–2026.
https://jutge.org