This answer will use both Inclusion-Exclusion and Stars and Bars. See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.
For Stars and Bars theory, see this article and this article.
$\underline{\text{Part a}}$
How many $~x \in \mathbb{Z}~$, with $~104050607080 \leq x \leq 908070605040,~$ can be formed using the digits of $~106506506503,~$ such that $~x~$ is divisible by $~20~$ and contains the string "$036$" as a substring?
Let the multiset $~A~$ denote $~\{0,0,0,0,1,3,5,5,5,6,6,6\}.~$ Since the lower and upper bounds for $~x~$ are each $~12~$ digit numbers, and $~A~$ contains exactly $~12~$ elements, when constructing $~x,~$ each element in $~A~$ must be used exactly once.
With respect to the constraints:
- The upper bound can be ignored, because $~A~$ does not contain a $~9.$
- The lower bound will be violated if and only if $~x~$ begins either "0", or "100" or "103".
- Since $~A~$ contains only one $~3,~$ the "036" string can only occur once. Reading the digit positions from left to right, the "036" string must start in one of the digit positions $~1~$ through $~10~$ inclusive.
- The divisibility by $~20,~$ constraint will be violated if and only if $~x~$ does not end in either "00" or "60".
Using Inclusion-Exclusion, let the set $~S~$ denote the set of all $~12~$ digit numbers constructed from the set $~A,~$ that contain the string "036". Let $~S_1~$ denote the subset of $~S~$ where the lower bound is violated. Let $~S_2~$ denote the subset of $~S~$ where the divisibility by $~20~$ is violated.
Then, the desired computation is
$$|~S~| - |S_1 \cup S_2| \\ = | ~S~| - |~S_1~| - |~S_2~| + |~ S_1 \cap S_2~|.\tag1 $$
$\underline{\text{Computation of} ~| ~S ~|}$
The "036" can occur in any of $~10~$ positions. For each such position, the remaining elements of $~\{0,0,0,1,5,5,5,6,6\}~$ need to be distributed among the $~9~$ remaining positions. Therefore,
$$| ~S~| = 10 \times \frac{9!}{3! ~3! ~2!} = 50400.$$
$\underline{\text{Computation of} ~| ~S_1 ~|}$
There are $~5~$ separate cases to consider.
The number begins "036".
The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} = 5040.$
The number begins "0", with the "036" string occurring in one of positions 2 through 10 inclusive.
The computation is $~\displaystyle 9 \times \frac{8!}{3! ~2! ~2!} = 15120.$
The number begins "1036".
The computation is $~\displaystyle \frac{8!}{3! ~3! ~2!} = 560.$
The number begins "10036".
The computation is $~\displaystyle \frac{7!}{3! ~2! ~2!} = 210.$
The number begins "100", with the "036" string occurring in one of positions 4 through 10 inclusive.
The computation is $~\displaystyle 7 \times \frac{6!}{3! ~2!} = 420.$
Therefore,
$$|~S_1~| = 5040 + 15120 + 560 + 210 + 420 = 21350.$$
$\underline{\text{Computation of} ~| ~S_2 ~|}$
There are $~3~$ separate cases to consider.
The number ends "036".
The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} = 5040.$
The number has "036" in position 9, but does not end in "0".
The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} - \frac{8!}{3! ~2! ~2!} = 3360.$
The number has "036" in one of positions 1 thru 8 inclusive, but does not end in either "60" or "00".
The computation is
$~\displaystyle 8 \times \left[ ~\frac{9!}{3! ~3! ~2!} - \frac{7!}{3! ~2!} - \frac{7!}{3! ~2!} ~\right] = 33600.$
Therefore,
$$|~S_2~| = 5040 + 3360 + 33600 = 42000.$$
$\underline{\text{Computation of} ~| ~S_1 \cap S_2 ~|}$
There are $~9~$ cases to consider.
The number begins "036" but does not end in either "00" or "60".
The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} - \frac{7!}{3! ~2!} - \frac{7!}{3! ~2!} = 4200.$
The number begins "0" and ends in "036".
The computation is $~\displaystyle \frac{8!}{3! ~2! ~2!} = 1680.$
The number begins "0", has "036" starting in position 9, but does not end in "0".
The computation is $~\displaystyle \frac{8!}{3! ~2! ~2!} - \frac{7!}{3! ~2!} = 1260.$
The number begins "0", has "036" starting in one of positions 2 through 8, but does not end in either "00" or "60".
The computation is
$\displaystyle 7 \times \left[ ~\frac{8!}{3! ~2! ~2!} - \frac{6!}{3! ~2!} - \frac{6!}{3!}~\right] = 10500.$
The number begins "1036" but does not end in either "00" or "60".
The computation is $~\displaystyle \frac{8!}{3! ~3! ~2!} - \frac{6!}{3! ~2!} - \frac{6!}{3! ~2!} = 440.$
The number begins "10036" but does not end in either "00" or "60".
The computation is $~\displaystyle \frac{7!}{3! ~2! ~2!} - \frac{5!}{3! ~2!} - \frac{5!}{3!} = 180.$
The number begins "100" and ends in "036".
The computation is $~\displaystyle \frac{6!}{3! ~2!} = 60.$
The number begins "100", has "036" starting in position 9, but does not end in "0".
The computation is $~\displaystyle \frac{6!}{3! ~2!} - \frac{5!}{3! ~2!} = 50.$
The number begins "100", has "036" starting in one of positions 4 through 8, but does not end in "60".
The computation is
$\displaystyle 5 \times \left[ ~\frac{6!}{3! ~2!} - \frac{4!}{3!}~\right] = 280.$
Therefore,
$$|~S_1 \cap S_2 ~| \\= 4200 + 1680 + 1260 + 10500 + 440 + 180 + 60 + 50 + 280 \\= 18650.$$
$\underline{\text{Final Computation}}$
$$| ~S~| - |~S_1~| - |~S_2~| + |~ S_1 \cap S_2 ~| \\= 50400 - [21350 + 42000] + 18650 = 5700.$$
$\underline{\text{Part b}}$
b.) How many solutions are there to the equation ( $x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 = 8004$ ), where ( $x_1, \ldots, x_8 \in \mathbb{Z}$ ) and ( $x_1, \ldots, x_8 \geq 0$ ), with the following constraints:
- ( $x_1 \geq 49$ ),
- ( $300 \leq x_3 \leq 399$ ),
- ( $550 \leq x_5 \leq 749$ ),
- ( $x_6 \geq 4$ ),
- ( $x_1 + x_7 + x_8 = 350$ ),
- ( $2x_1 + x_3 + x_5 \geq 950$ )?
The first portion of your analysis for part (b) looks good. However, I would organize things differently.
Set
- $y_1 = x_1 - 49 \implies 0 \leq y_1.$
- $y_3 = x_3 - 300 \implies 0 \leq y_3 \leq 99.$
- $y_5 = x_5 - 550 \implies 0 \leq y_5 \leq 199.$
- $y_6 = x_6 - 4 \implies 0 \leq y_6.$
- For $~i \in \{2,4,7,8\}, ~$ set $~y_i = x_i.~$
So, at this point, you are working exclusively in the variables $~y_1, \cdots, y_8,~$ where all of these variables are integers with a lower bound of $~0,~$ and only the variables $~y_3~$ and $~y_5~$ have an upper bound.
Then, the constraints to be satisfied are
- Constraint 1: $~y_1 + \cdots + y_8 = 8004 - 903 = 7101.$
- Constraint 2: $~y_1 + y_7 + y_8 = 350 - 49 = 301.$
- Constraint 3: $~2y_1 + y_3 + y_5 \geq 950 - [98 + 300 + 550] = 2.$
At this point, it is time to come up with a strategy.
Since the minimum value of $~2y_1 + y_3 + y_5~$ is $~0,~$ the number of ordered triples $~(y_1, y_3, y_5)~$ that are in violation can be individually scrutinized.
Further, Based on Constraint 2, Constraint 1 can be re-expressed as
- Constraint 4: $~y_2 + \cdots + y_6 = 7101 - 301 = 6800.$
Further, Constraint 4 and Constraint 2 share no variables. Therefore, if you temporarily ignore Constraint 3, the number of satisfying solutions to Constraint 4 and Constraint 2 are
$$\text{[Number of solutions to Constraint 4}] \\\times [\text{Number of solutions to Constraint 2}].
$$
So, my overall approach to part b will be to temporarily ignore Constraint 3, compute the corresponding product, and then deduct the number of solutions where Constraint 3 is violated. When needed, I will follow the model in this answer.
$\underline{\text{Number of solutions to Constraint 2}}$
Constraint 2 is
- $y_1 + y_7 + y_8 =301.$
- $y_1, y_7, y_8 \in \Bbb{Z_{\geq 0}}.$
The number of solutions is
$$\binom{303}{2}.$$
$\underline{\text{Number of solutions to Constraint 4}}$
Constraint 4, with the upper bounds included is
- $y_2 + \cdots + y_6 = 6800.$
- $y_2, \cdots, y_6 \in \Bbb{Z_{\geq 0}}.$
- $y_3 \leq 99.$
- $y_5 \leq 199.$
Let :
- $~S~$ denote the set of all solutions to the above problem, where the upper bound constraints on $~y_3~$ and $~y_5~$ are ignored.
- $~S_1~$ denote the subset of $~S~$ where $~y_3 \geq 100.$
- $~S_2~$ denote the subset of $~S~$ where $~y_5 \geq 200.$
Then, the desired computation is
$$| ~S ~| - | ~S_1~| - | ~S_2 ~| + | ~S_1 \cap S_2 ~|.$$
Following the linked model, the computation is
$$\binom{6804}{4} - \binom{6704}{4} - \binom{6604}{4} + \binom{6504}{4}.$$
$\underline{\text{Number of combined solutions to Constraints 2 and 4}}$
The computation is
$$\binom{303}{2}$$
$$\times \left[ ~\binom{6804}{4} - \binom{6704}{4} - \binom{6604}{4} + \binom{6504}{4} ~\right].$$
$\underline{\text{Individual} ~y_1, y_3, y_5 ~\text{Violations}}$
The constraint to be violated is
$$2y_1 + y_3 + y_5 \geq 2.$$
Since $~y_1, y_3, y_5~$ must each be non-negative integers, the following is the complete set of ordered triplets $~(y_1, y_3, y_5)~$ that are in violation:
$$\{ ~(0, 0, 0), ~(0,0,1), ~(0,1,0) ~\}.$$
So, you simply repeat all of the analysis so far, three times. once for each of the possible $~(y_1, y_3, y_5)~$ violations. You obtain three products, sum them, and then deduct that from the product already computed.
$\underline{\text{Number of Violation Solutions to Constraint 2}}$
Here, $~y_1~$ is set to $~0.~$ So, the number of violation solutions to Constraint 2 is
$$\binom{302}{1}.$$
$\underline{\text{Number of Violation Solutions to Constraint 4}}$
With $~y_3, y_5~$ each fixed at either $~0~$ or $~1,~$ you will have (in effect) three variables, instead of $~5.~$ Further, the sums of the three violation constraints will either be $~6800, 6799,~$ or $~6799.$
Therefore, the number of violation solutions to Constraint 4 is
$$\binom{6802}{2} + \left[ ~2 \times \binom{6801}{2} ~\right].$$
$~\underline{\text{Total Number of Violation Solutions}}$
$$\binom{302}{1} \times \left\{ ~\binom{6802}{2} + \left[ ~2 \times \binom{6801}{2} ~\right] ~\right\}.$$
$~\underline{\text{Final Computation.}}$
Set
$$B = \binom{303}{2}$$
$$\times \left[ ~\binom{6804}{4} - \binom{6704}{4} - \binom{6604}{4} + \binom{6504}{4} ~\right].$$
Set
$$C = \binom{302}{1}\times \left\{ ~\binom{6802}{2} + \left[ ~2 \times \binom{6801}{2} ~\right] ~\right\}.$$
Then, the final computation is
$$B - C.$$
May I ask you why you haven't posted a reply and posted instead multiple comments? Would I be asking too much for a reply with a step-by-step solution?
– zaxunobi Jul 25 '24 at 15:24\[...\]and\(...\), which works in latex but does not work in mathjax. I will soon post a complete answer to both questions. – user2661923 Jul 27 '24 at 16:20