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 computes in how many ways the gymnast can finish the exercise at every position. 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 in order the positions where the gymnast can finish, together with the number of ways modulo .
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T11:18:06.871Z
© Jutge.org, 2006–2026.
https://jutge.org