If k is small, then you just need to keep track of the multiset of path-lengths so far, discarding those which exceed k. If k is large, then there's a generating function argument against an efficient solution.
–
John Wiltshire-GordonFeb 12 '12 at 20:44

Thanks John, can you expand on the generating function argument, or give me a pointer? By the way, the elements of A can be negative.
–
Alex FlintFeb 15 '12 at 10:31

@Alex Flint If the entries of A are negative, we may add some constant to each entry so they all become positive. Unfortunately, this means that k will be large and your problem is hopeless in general.
–
John Wiltshire-GordonFeb 15 '12 at 18:10

These coefficients have a combinatorial interpretation: they count the number of paths of a given sum! For instance, the term $4x^7$ signals that four paths sum to 7.

Unfortunately, we are now in the position of asking for the sum of the coefficients of $f(x)$ in a certain range of degrees. This problem is NP-complete because an efficient algorithm would solve the subset sum problem.

Taking $k=0$, $B$ is asking about subsets with negative sum, while $B'$ is asking about subsets with nonpositive sum (each of which will appear twice). Subtracting half the answer for $B'$ from the answer for $B$, we obtain the number of ways to produce $0$ as a subset sum:

$$14-26/2 = 1.$$

This number is not zero, so there exists a subset with sum 0. Worse, this tells us how many such subsets there are, answering a question in #P.