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?
I am reposting this exercise (already answered here) because I wonder if there is a less-time consuming approach. My professor told me that a solution by complement, for this exercise, is too much time-consuming and further it would requires to analyse too many cases. He suggested to count directly the substrings that satisfy those conditions but honestly I have no clue how to do this. How can exercise be solved more quickly?
Edit:
- Please note that substring can only appear once.
- Please note that the leftmost digit of any positive integer is not permitted to equal 0.
- Please also note that I am not allowed to use computational tools otherwise I would have solved this exercise in C++ or Java.
Solution Outline (as my professor requested)
Available Digits:
- We can only use the digits of the number ( 106506506503 ). The digits are: ( 1, 0, 6, 5, 0, 6, 5, 0, 6, 5, 3 ).
- Thus, we have the digit frequencies:
- Three ( 0 )'s
- Three ( 6 )'s
- Three ( 5 )'s
- One ( 1 )
- One ( 3 )
Divisibility by 20:
- For ( x ) to be divisible by 20, the number must end in "00", as divisibility by 20 implies the number is divisible by both 5 and 4. This imposes the following restrictions:
- The last two digits must be "00".
- Therefore, at least two ( 0 )'s must be used at the end of ( x ).
- For ( x ) to be divisible by 20, the number must end in "00", as divisibility by 20 implies the number is divisible by both 5 and 4. This imposes the following restrictions:
Contains Substring "036":
- The number ( x ) must also contain the string "036" somewhere in its digits. This introduces another restriction:
- We must reserve the digits "036" somewhere within the number ( x ).
- The number ( x ) must also contain the string "036" somewhere in its digits. This introduces another restriction:
Total Number of Digits:
- The total length of ( x ) can be at most 12 digits because the number ( 106506506503 ) consists of 12 digits.
- Since two digits are used for the "00" at the end and three digits are reserved for "036", we are left with ( 12 - 5 = 7 ) digits to fill with the remaining available digits.
Combinatorial Setup:
- We now calculate how many valid combinations of digits can be formed, given the constraints.
- The process involves the following combinatorial choices:
- We first place the "036" somewhere in the number ( x ), excluding the last two positions (which are occupied by "00").
- Then, we fill in the remaining ( 7 ) positions using the available digits ( {1, 6, 5, 5, 6, 5, 6} ).
Calculating the Number of Valid Combinations:
- Using binomial coefficients, we calculate the number of ways to arrange the remaining digits.
Subtraction of Invalid Cases:
- The solution subtracts certain invalid cases where either the substring "036" does not appear, or the number is not divisible by 20.
- The total valid cases ( A ) are computed and invalid cases ( B ) are subtracted from it, yielding the final result ( A - B ).
Conclusion
By following this process, we compute the number of valid integers ( x ) that meet the given conditions. The approach combines the constraints of divisibility by 20, the inclusion of the substring "036", and the combinatorics of arranging the digits of ( 106506506503 ).
Can someone help me now in applying this process?