A gymnast is at the midpoint of a balance beam of length . The gymnast must jump times forward or backward, never leaving the bar. The -th jump has length . Write a program to compute all the positions where the gymnast can finish her exercise. The gymnast cannot skip any jump, nor change the order of the jumps.
Input consist of the length , the number , and the lengths . Assume , that is even, , and .
Assuming that the initial position is 0 (hence, the valid positions belong to ), print all the positions where the gymnast can finish. Every position must occur as many times as combinations of jumps make it possible.
You can print the solutions to this exercise in any order.
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T10:21:32.899Z
© Jutge.org, 2006–2026.
https://jutge.org