<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] We can count the total possible unique values of $4x-z$ by summing the size of the following 5 mutually disjoint sets of values:

*

*Non-positive values: corresponds to $x=0$, there are $21$ such values of $4x-z$ from $-20$ to $0$, corresponding to $z=0,1,2,\ldots , 20$.


*Positive values of form $\equiv 0 \pmod 4$: corresponds to $z=0$ and $x=1,2,\ldots, 20$, there are 20 such values.


*Positive values of form $\equiv 3 \pmod 4$: corresponds to $z=1$ and $x=1,2,\ldots, 19$, there are 19 such values.


*Positive values of form $\equiv 2 \pmod 4$: corresponds to $z=2$ and $x=1,2,\ldots, 18$, there are 18 such values.


*Positive values of form $\equiv 1 \pmod 4$: corresponds to $z=3$ and $x=1,2,\ldots, 17$, there are 17 such values.
Generalizing the above mod 4 cases, we have the following mutually disjoint sets of values:

*

*Non-positive values: corresponds to $x=0$, there are $21$ such values of $4x-z$ from $-20$ to $0$, corresponding to $z=0,1,2,\ldots, 20$.


*Positive values of form $\equiv -k \pmod 4$: corresponds to $z=k$ and $x=1,2,\ldots, (20-k)$, there are $20-k$ such values of $4x-z$, for $k \in \{0,1,2,3\}$.
Hence, the total number of distinct values of $4x-z$ will be $=21+\sum\limits_{k=0}^{3}(20-k)=21+80-6=95$
</s>