Equal sums (1)

Write a program that, given an integer number s and n integer numbers
x₁, …, x_(n), prints all the subsets (maybe with repeated numbers, but
using every x_(i) at most once) whose sum is exactly s.

Input

Input consists of an integer number s, followed by a number n > 0,
followed by x₁, …, x_(n).

Output

Print all the subsets whose sum is s that can be made up with
x₁, …, x_(n).

Information about the checker

You can print in any order both the solutions and the elements inside
each solution.

Hint

For this exercise, simple backtracking solutions are accepted. No
optimizations are required.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:03:20.226Z

© Jutge.org, 2006–2026.
https://jutge.org
