Module 2.2 · Counting and Probability
Advanced inclusion-exclusion
Inclusion-exclusion is the tool for "none of these bad things happens" and "every one of these things happens." At the AIME level you use it with many conditions at once, and the trick is organizing the terms so that each one is a simple count.
The general formula
For sets ,
Each element that lies in exactly of the sets is counted time, which is why the formula works.
In practice you almost always want the complement: the number of objects with none of the bad properties.
Inclusion-exclusion for 'none'
If objects are in total, and are the sets of objects with each bad property, then
where is the sum of over all choices of of the sets.
When the problem is symmetric, every intersection of sets has the same size , and .
Symmetry is what makes AIME problems workable. With conditions you would never list intersections, but if they all look alike you only need one count per .
Three standard families
Derangements. A permutation of objects with no fixed points is a derangement. Let be the permutations fixing object . Fixing specific objects leaves permutations, so
The first values are , , , , , , . They also satisfy .
To count permutations with exactly fixed points, choose which are fixed and derange the rest: .
Surjections. The number of functions from an -element set onto a -element set (every output used) is
Here is the set of functions that miss output .
Bounded stars and bars. To count solutions of with upper bounds, let be the solutions with too big. Shifting down turns each intersection into an ordinary stars-and-bars count.
Common mistake
Don't stop after subtracting the singles. Objects with two bad properties were subtracted twice and must be added back, and so on. If your answer is negative or suspiciously small, you probably forgot a term.
Worked example: Divisibility
How many integers from to are divisible by none of , , ?
Use for the multiples of :
The pair terms use , , and the triple term uses .
Worked example: Exactly two fixed points
Six letters are placed at random into six addressed envelopes, one per envelope. The probability that exactly two letters land in their correct envelopes is in lowest terms. Find .
Choose the two correct letters in ways; the other four must be deranged, in ways. The probability is , so .
Worked example: Every worker gets a job
In how many ways can different tasks be assigned to workers so that every worker gets at least one task?
All assignments: . Missing a given worker: , for each of workers. Missing two given workers: , for each of pairs. So the count is .
Worked example: Couples not side by side
Four married couples sit in a row of chairs in random order. The probability that no husband sits next to his wife is in lowest terms. Find .
Let be the seatings where couple sits together. For specific couples together, glue each into a block: orders of the units, times for the order inside each block. So
The probability is , so .
Tip
Before computing, write the answer as and find a formula for . If you can't describe in one line, rethink what your sets are.
Practice
How many integers from to are divisible by none of , , ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Six people each bring a gift to a party, and the gifts are redistributed at random so that each person gets one gift. The probability that nobody receives their own gift is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Let be the number of ways to place distinguishable balls into distinguishable boxes so that no box is empty. Find the remainder when is divided by .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many strings of length using the letters , , , contain each of , , and at least once?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Three couples sit at random around a round table with seats. Seatings that differ only by a rotation are considered the same. The probability that no one sits next to their partner is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the number of ordered triples of positive integers with and .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many integers from to are perfect squares, perfect cubes, or perfect fifth powers?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the number of arrangements of the eight letters in a row such that no two identical letters are adjacent.
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 2012 AIME I, Problem 3: meals served so that exactly one person gets what they ordered, a derangement-style count.
- 2014 AIME II, Problem 9: complementary counting for subsets of chairs around a circle.