How many strings of length formed from the digits , , , , are there such that for each , at least of the digits are less than ? (For example, satisfies this condition because it contains at least digit less than , at least digits less than , at least digits less than , and at least digits less than . The string does not satisfy the condition because it does not contain at least digits less than .)
- A)
- B)
- C)
- D)
- E)
Answer
E
Key insight
In a bad string, the smallest failing j has exactly j-1 digits below j-1 (a good string) and the rest at least j; recursing gives 1, 3, 16, 125, 1296.
Solution
Call a string of length over the digits good if for every at least of its digits are less than . Let be the number of good strings, with (the empty string). We want .
Count the bad strings by their smallest failing . Condition holds (at least digits below ) while condition fails (at most digits below ). Digits below are also below , so exactly digits are below , and all of them are actually below . Among themselves these digits satisfy conditions , so they form a good string of length . The other digits are each at least , chosen from the values . Choosing the positions of the small digits,
(The case never fails.) Compute:
- .
- .
- .
- .
- .
The answer is .
Why this works
The condition is monotone in , so a failing string has a first failure, and at that point the string splits cleanly into a good short string of small digits and a block of unconstrained large digits. That split is what makes complementary counting recursive. These are the parking functions, and : are .
Alternative approach
Under time pressure, compute the small cases directly: , (strings ), by a short list or the recursion. Spotting suggests , which is the only choice of that form; one more step () confirms the pattern.
The trap
Miscounting the free digits in the complement: each must be at least j, so there are 5 - j values for it, not 5 - j + 1 or 5.
Common mistakes
- Miscounting the free digits in the complement: each must be at least j, so there are 5 - j values for it, not 5 - j + 1 or 5.
- Counting only the sorted digit patterns (multisets) and forgetting to multiply each by its number of rearrangements.
Techniques
Count the complement and subtract from the total · Compute small cases, spot the pattern, generalize · Define states/recurrence and iterate