This may be a bit trivial (apologies if it is), but I was wondering if there was an elementary way to compute the cardinality of the solution set in the following situation:
How many solutions would exist to the equation $$2a + 2b + 4c + 4d = 8$$ if $a,b,c,d$ are distinguishable nonnegative integers?
Just to clarify, when I say "distinguishable", I mean that even if $a = b$, they represent different objects, and thus the solutions $(2,0,1,0)$, $(2,0,0,1)$, $(0,2,1,0)$, and $(0,2,0,1)$ are all distinct.
My real question, for which the trivial case above is just a motivating example, is:
More generally, if we are given $r$ strictly positive integers $p_1,\ldots,p_r$ (not necessarily distinct), how many solutions exist to the following equation for some moderately large $n\in\mathbb{N}$? $$\sum_{i=1}^r p_i a_i = n$$ if $a_1,\ldots,a_r$ are distinguishable nonnegative integers?
I want to say that this is related to the pigeonhole principle, because using that, I was able to count exactly 14 such solutions in the trivial case of 4 nonnegative integers. That being said, I'm not sure about the more general case.
There's a simple recursive algorithm to compute this. Let $N(p_1,\ldots,p_r,n)$ be the number of nonnegative integer solutions to $\sum\limits_{i=1}^r p_ia_i=n$. Then $$\begin{align} N(p_1,n) &=\begin{cases}1&\text{if } p_1\mid j\\ 0&\text{otherwise}\end{cases} \\ N(p_1,\ldots,p_r,n) &= \sum_{j=0}^{\lfloor n/p_r\rfloor}N(p_1,\ldots,p_{r-1},n-p_rj) \end{align}$$ While naive implementation of this algorithm has exponential runtime in $r$, using dynamic programming we can get the runtime down to $O(n^2r)$. In pseudocode:
In Python:
As a test, numSolutions([2,2,4,4],8) returns 14.