Balance beam (2)

A gymnast is at the midpoint of a balance beam of length m. The gymnast
must jump n times forward or backward, never leaving the bar. The i-th
jump has length ℓ_(i). 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

Input consist of the length m, the number n, and the lengths
ℓ₁, …, ℓ_(n). Assume 2 ≤ m ≤ 10³, that m is even, 0 ≤ n ≤ 10⁴, and
1 ≤ ℓ_(i) ≤ 100.

Output

Assuming that the initial position is 0 (hence, the valid positions
belong to [−m/2, m/2]), print in order the positions where the gymnast
can finish, together with the number of ways modulo 10⁸ + 7.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:18:06.871Z

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