<s>[INST] Number of possible values of $4x-z$ if $x+y+z=20$ Given that $x, y,z$ are non negative integers such that $x+y+z=20$. If $S$ is the set of all possible values of $4x-z$.Find $n(S)$.
My try:
By stars and bars number of non negative integer solutions of $x+y+z=20$ is $\binom{22}{2}=210$
Among these $210$ ordered triplets of $(x,y,z)$ we need to find number of possible values taken by $4x-z$.
Obviously the least value taken by $4x-z$ is $-20$ when $x=0,z=20$.
The next value taken by $4x-z$ is $-19$ when $x=0,z=19$ and so on.
So once we fix $x=0$ ,since $z$ varies from $[0,20]$ number of values taken by $4x-z$ is $21$.
But when we fix $x=1$, we get some overlaps. For example when $x=1,z=18$ we have $4x-z=-14$ and this value has already been counted in the previous case when $x=0,z=14$.
So any way to count total number of values taken by $4x-z$ excluding overlaps?
 [/INST] For a given value of $x$, $z$ can range from $0$ up to $20-x$. This means that
$$D_a := \{4a-z \mid a + y + z = 20\} = \{5a-20, 5a-19, \ldots, 4a\}$$
(note that $5a-20 \leq 4a$ when $0 \leq x \leq 20$) where $a$ is fixed. Notice also that $4a \geq 5(a+1)-20$ for $a \leq 15$. This means that $D_a$ and $D_{a+1}$ overlap for $a \leq 15$. As a result, we find that
$$D_0 \cup D_1 \cup D_2 \cup \cdots \cup D_{16} = \{5 \cdot 0 - 20, \ldots, 4 \cdot 16\} = \{-20, \ldots, 64\}$$
For $a \geq 17$, $D_a$ is disjoint from $D_{a-1}$ and $D_{a+1}$. This means that
\begin{align}
n(\{4x-z \mid x + y + z = 20\}) &= n(D_0 \cup D_1 \cup \cdots \cup D_{20}) \\
&= n(D_0 \cup \cdots \cup D_{16}) + n(D_{17}) + n(D_{18}) + n(D_{19}) + n(D_{20}) \\
&= 85 + 4 + 3 + 2 + 1 = \boxed{95}
\end{align}
</s>