A friend of mine ask me yesterday a problem, however, the interesting part for me it is not his problem, but what I will ask here.

I want to know the optimal complexity of an algorithm (I mean the complexity of the more efficient algorithm) that solves the following problem:

Input: $n\in \mathbb N, h\in \mathbb N, (a_1,\ldots,a_n)\in \mathbb N^n.$

Output: Cardinality of the set $\{(j_1,\ldots,j_n)\in \mathbb N^n:\sum_{i=1}^n j_i a_i=h\}.$

Hope the question does make sense.