Number of integer solutions to linear equation with restrictions

915 Views Asked by At

How many integer solutions does the equation $a + b + c = n$ have, when $1 \le a, b, c \le m$?

I know how solve it for $n$ variables and no constraints, but i have no idea how to tackle this one.

2

There are 2 best solutions below

0
On BEST ANSWER

Let $a' = a-1, b'=b-1, c'=c-1$. Every solution of the equation $a'+b'+c'=n-3$ corresponds to a solution of the original equation, and $0\le a',b',c' \le m-1$.

Now, figure out how many solutions exist with no upper bound restrictions. You say you know this. There are $\dbinom{n-1}{2}$ solutions. Now, use the Inclusion/Exclusion principle to count when $a',b',c'$ violate their upper bounds. If $a'>m-1$, then $a'>=m$, so let $a''=a'-m$. Now, there is a one-to-one correspondence between solutions of the equation $a''+b'+c'=n-3-m$ and solutions of $a'+b'+c'=n-3$ where $a'\ge m$.

So, by Inclusion/Exclusion, you have the total number of solutions: $\dbinom{n-1}{2}-3\dbinom{n-1-m}{2}+3\dbinom{n-1-2m}{2}-\dbinom{n-1-3m}{2}$ where we choose the definition that $\dbinom{k}{2} = 0$ for all $k<0$.

0
On

it is equivalent of finding : number of way of distributing n identical toffees among 3 persons such that each person gets atleast 1 toffe and not more than m toffee:

to get the answer you should find

coefficient of $x^{n}$ in expansion of $(x+x^2+......+x^m)^3$

coefficient of $x^{n-3}$ in expansion of $(1-x^m)^3(1-x)^{-3}$

coefficient of $x^{n-3}$ in expansion of $(1-3x^m+3x^{2m}-x^{3m})(1-x)^{-3}$

coefficient of $x^{n-3}$ in expansion of $(1-3x^m+3x^{2m}-x^{3m})\left(\displaystyle \sum_{r=0}^{r=\infty} \ \ ^{r+2}C_{2} \ \ .x^r\right)$

$=^{n-1}C_{2}-3.(^{n-1-m}C_{2})+3.(^{n-1-2m}C_{2})-(^{n-1-3m}C_{2})$