Number of ways to divide $160$ into three parts In how many ways can we divide $160$ into three parts, each with at least $40$ and at most $60$?


The amounts can only be integers. Please help me solve this, I don't really get exercises with at least and at most conditions.
SOLUTION:

This can be very easily solved by Partition method and then using generating function (other name: INTEGRAL EQUATION METHOD).

Let $\displaystyle x+y+z = \$160 \ \ $ as each gets atleast $\$40$  so just divide $\$40$ to each of them before hand.

Then the equation becomes $$\displaystyle a+b+c = \$40 \ \ $$ for some $a,b,c$.

Now we need to divide $\$20$ among $a,b,c$ as at max each can get $\$60$. 

Thus By generating function or Integral equation method we can convert the following equation into this form :-

$$\displaystyle (1 + r^1 + r^2 + ... + r^{20})^3 = r^{40} $$ 

Where the coefficient of $ r^{40} $ determines the number of possible solutions to the equation. By GP-summation we convert this into:

$$\displaystyle \frac {(1-r^{21})^3}{(1-r)^3} = r^{40} \implies (1-r^{21})^3(1-r)^{-3} = r^{40} $$

Now if we ibserve it then we can see that the terms that matter to us in $({1-r^{21}})^3$ is just $({1-3r^{21}})$, as rest of the terms have exponents greater than $40$.

So, we get the coefficient of $r^{40}$ by $\displaystyle \binom {40 + 3-1}{3-1} - 3 \times \binom {19 + 3-1}{3-1}$, thus the answer is:

$$\displaystyle \binom {42}{2} - 3\binom {21}{2} = 231 .$$
All of the parts are greater than or equal to $40$, 

So the sum will be at least $120$.

Now the remaining $40$ needs to be partitioned into $3$ groups $A,B,C$ so that none of the groups have more than $20$

The total ways to do this without the $20$ limit restriction is:

$A+B+C=40$, hence $\binom{42}{2}$ ways. 

Now we have to subtract ways in which  $1$ group has more than $20$ 

Lets say that $A \gt 20$

So $B+C \lt 40-20$, or in other words, $B+C+D*=19$

This can be done in:  $\binom{21}{2}$ ways

Now any of $A,B,C$ could have been $\gt 20$

$3\cdot \binom{21}{2}$

And finally, 

$\binom{42}{2}-3\cdot \binom{21}{2}$

*$D$ was added as another variable to account for the fact that if $B+C=18$, $D=1$, similarly if $B+C=12$, $D=7$ and so on