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
Count the bad strings by the first condition they break. At that point the string splits into a smaller good string of low digits plus a block of high digits.
Solution
There are strings in all. It is easier to count the strings that fail, sorted by the first condition they break.
Step 1: small good strings we will need. Call a string "good" if it passes all its conditions.
- Length , digits , needing at least one digit less than (a ): . That is strings.
- Length , digits , needing at least one and at least two digits less than . Out of strings, have no , and have exactly one with two s (). So are good.
Step 2: count the bad strings of length 5.
- First failure at : no digit is . Each digit is one of : strings.
- First failure at : there is a , but at most one digit less than . So there is exactly one , no s, and the other four digits are or . Place the in ways; the rest give . Total .
- First failure at : at least two digits are less than , but at most two are less than . So exactly two digits are small (both or ), and they must include a : they form one of the good pairs from Step 1. The other three digits are or . Choose the two spots in ways: .
- First failure at : at least three digits are less than , but at most three are less than . So exactly three digits are small (each , or ), and they must pass the earlier conditions: they form one of the good strings of length . The other two digits must be . Choose the three spots in ways: .
Each bad string has exactly one first failure, so nothing is counted twice. Bad strings: .
Step 3: subtract. Good strings: .
The answer is .
Why this works
The conditions build on one another, so a failing string has a first failure, and at that moment it splits cleanly into a shorter good string of small digits plus a block of large digits. That is why counting the failures works and why it reuses the counts for shorter strings. The counts for lengths to are , which are , a pattern worth remembering.
Alternative approach
Under time pressure, find the small cases and guess the pattern. Length (digit only): string. Length : strings. Length : strings (Step 1 above). The numbers are , which suggests length gives , and that is one of the choices. Length can be checked the same way as Step 2: , which supports the pattern.
The trap
Miscounting the high digits: after the first failure at j, each remaining digit must be at least j, so it has 5 - j possible values.
Concise 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 .
Review in the AoPS books
- Intermediate Counting & Probability, Chapter 10: Recursion (§10.2, §10.3)
- Introduction to Counting & Probability, Chapter 1: Counting Is Arithmetic
- Introduction to Counting & Probability, Chapter 2: Basic Counting Techniques (§2.3)
- Prealgebra, Chapter 15: Problem-Solving Strategies (§15.1)
Techniques
Count the complement and subtract from the total · Compute small cases, spot the pattern, generalize · Define states/recurrence and iterate