To determine the number of five-digit numbers that satisfy the following conditions:
- Do not start with 0.
- Are divisible by 3 (implicitly satisfied since the sum of digits is 18).
- Have a sum of digits equal to 18.
- Contain exactly three distinct digits.
Let's break down the problem step-by-step.
Step 1: Understanding the Problem
- Five-digit numbers: Numbers ranging from 10000 to 99999.
- Sum of digits is 18: The digits ( d_1, d_2, d_3, d_4, d_5 ) satisfy ( d_1 + d_2 + d_3 + d_4 + d_5 = 18 ).
- Exactly three distinct digits: Among the five digits, there are exactly three unique values.
Step 2: Analyzing Digit Combinations
Given that there are exactly three distinct digits, the possible distributions (multiplicities) of these digits in a five-digit number are:
- 3-1-1: One digit appears three times, and the other two digits appear once each.
- 2-2-1: Two digits appear twice each, and the third digit appears once.
We'll analyze each case separately.
Case 1: Multiplicity 3-1-1
Structure: ( x, x, x, y, z ) where ( x ), ( y ), and ( z ) are distinct digits.
Constraints:
- ( x \neq 0 ) (since the number cannot start with 0).
- ( 3x + y + z = 18 ).
Steps:
-
Find all valid triples ( (x, y, z) ):
- Iterate ( x ) from 1 to 6 (since ( 3x \leq 18 )).
- For each ( x ), find ( y ) and ( z ) such that ( y + z = 18 - 3x ), ensuring all digits are distinct.
-
Calculate Valid Combinations:
- Total valid triples found: 13.
- Among these, 3 triples include a zero (( y ) or ( z = 0 )), which require special handling to avoid starting with zero.
-
Compute Arrangements:
- Without zero: Each of the 10 triples has ( \frac{5!}{3!1!1!} = 20 ) valid arrangements.
- With zero: Each of the 3 triples has ( 20 - 4 = 16 ) valid arrangements (excluding cases where zero is the first digit).
-
Total for 3-1-1:
[
10 \times 20 + 3 \times 16 = 200 + 48 = 248
]
Case 2: Multiplicity 2-2-1
Structure: ( x, x, y, y, z ) where ( x ), ( y ), and ( z ) are distinct digits.
Constraints:
- ( x \neq 0 ) or ( y \neq 0 ) if they appear in the first digit.
- ( 2x + 2y + z = 18 ).
Steps:
-
Find all valid triples ( (x, y, z) ):
- Iterate through possible pairs ( (x, y) ) and find ( z = 18 - 2x - 2y ), ensuring all digits are distinct.
- Total valid sets found: 15.
-
Categorize Sets:
- Category A: No zeros (( 8 ) sets).
- Category B: Zeros in the double digits (( 3 ) sets).
- Category C: Zero in the single digit (( 4 ) sets).
-
Compute Arrangements:
- Category A: Each of the 8 sets has ( \frac{5!}{2!2!1!} = 30 ) valid arrangements.
- Category B: Each of the 3 sets has ( 30 - 12 = 18 ) valid arrangements (excluding cases where zero is the first digit).
- Category C: Each of the 4 sets has ( 30 - 6 = 24 ) valid arrangements (excluding cases where zero is the first digit).
-
Total for 2-2-1:
[
8 \times 30 + 3 \times 18 + 4 \times 24 = 240 + 54 + 96 = 390
]
Final Calculation
Adding both cases together:
[
248 \text{ (from 3-1-1)} + 390 \text{ (from 2-2-1)} = 638
]
Therefore, the total number of five-digit numbers satisfying all the given conditions is 638.
Answer: 638