Clever Counting & Logic

Study Sheet

Clever Counting & Logic

Complements, casework, and parity

Counting Without Listing

Tip
The complement trick

Sometimes the easiest way to count what you want is to count what you do NOT want: ∣A∣=∣total∣−∣not A∣|A| = |\text{total}| - |\text{not } A|.

In plain terms. Count everything, count the "bad" ones, subtract.

Example. How many 3-digit numbers contain at least one 7? Total: 900900. With no 7s: 8⋅9⋅9=6488 \cdot 9 \cdot 9 = 648. So 900−648=252900 - 648 = 252.

Why "not" is so often easier: a condition like "contains at least one 77" can be met in many overlapping ways (the 77 could be in any position, or in several), but its opposite, "contains no 77", is one restriction applied to every digit separately — and independent restrictions multiply. Parity arguments are the same kind of shortcut: they replace a computation by a count of odd terms.

Concept
Casework that stays organized

Split the count into cases that do not overlap and together cover everything, then add the case counts.

In plain terms. Sort the possibilities into non-overlapping piles and count each pile.

Example. Two dice sum to 55: the cases are (1,4),(2,3),(3,2),(4,1)(1,4), (2,3), (3,2), (4,1) — exactly 44 ways.

Tip
Parity (odd/even) arguments

The parity of a sum depends only on how many ODD terms it has — an even number of odd terms gives an even sum.

In plain terms. You can often decide odd vs. even without computing anything.

Example. 1+2+⋯+9=451 + 2 + \cdots + 9 = 45 is odd because it contains five odd terms, and 55 is odd.

Example
Worked: numbers without a 5

How many integers from 11 to 999999 do not contain the digit 55?

Step 1 — pad with zeros so every number has three digits, 000000 to 999999.

Step 2 — each digit avoids 55 in 99 ways, independently: 93=7299^3 = 729 strings.

Step 3 — that includes 000000, which is not in the range: 729−1=728729 - 1 = 728. Padding makes the positions independent; removing 000000 is the price.

Example
Worked: an impossible handshake

Can 77 people each shake hands with exactly 33 of the others?

Step 1 — add up the handshakes each person makes: 7⋅3=217\cdot3 = 21.

Step 2 — every handshake involves two people, so this total counts each handshake twice and must be even.

Step 3 — 2121 is odd. Impossible. Parity settled it without trying a single arrangement.

Side note
Where it goes wrong

Padding without un-padding. Counting "11 to 999999" as 000000 to 999999 is a good trick, but the extra string 000000 has to be removed, and for questions like "how many are three-digit numbers?" the padded ones with a leading 00 must go too.

Try it
Try it: an even digit

How many four-digit numbers contain at least one even digit?

Show the answer

Total four-digit numbers: 90009000. With every digit odd: 54=6255^4 = 625 (the first digit is odd, so it is automatically not 00). At least one even digit: 9000−625=83759000 - 625 = \mathbf{8375}.

Paths, Pairs and Handshakes

Tip
Lattice paths

Paths from (0,0)(0,0) to (m,n)(m,n) moving only right and up: (m+nn)\dbinom{m+n}{n}, because a path is a word in mm Rs and nn Us.

From (0,0)(0,0) to (4,3)(4,3) there are (73)=35\dbinom73 = 35 paths. Blocked squares are handled by subtraction: count all paths, then subtract those through the blocked point, which is a product of two smaller path counts. That "through a point" factorisation — paths to it, times paths from it — is the whole technique.

Tip
Handshakes and pairs

nn people each shaking every other hand once make (n2)=n(n−1)2\dbinom{n}{2} = \dfrac{n(n-1)}{2} handshakes; the same count gives diagonals of a polygon, n(n−3)2\dfrac{n(n-3)}{2}, after removing the nn sides.

Ten people make 4545 handshakes; a decagon has 10⋅72=35\dfrac{10\cdot7}{2} = 35 diagonals. The trap is the factor of two: counting "each of 1010 people shakes 99 hands" gives 9090, which counts every handshake from both ends. Whenever a count seems to be exactly twice what it should be, look for an ordered/unordered mismatch.

Example
Worked: paths avoiding a point
1111123410371141112617start
Each point gets the sum of the numbers to its left and below; the blocked point gets 00.

How many right/up paths from (0,0)(0,0) to (4,3)(4,3) avoid the point (2,1)(2,1)?

Step 1 — all paths: (73)=35\dbinom73 = 35.

Step 2 — paths through (2,1)(2,1): (31)⋅(42)=3⋅6=18\dbinom31\cdot\dbinom42 = 3\cdot6 = 18.

Step 3 — subtract: 35−18=1735 - 18 = 17. The middle step is the product rule: a path through (2,1)(2,1) is a path to it followed by a path from it, chosen independently.

Example
Worked: diagonals backwards

Which polygon has exactly 2020 diagonals?

Step 1 — the diagonal count is n(n−3)2\dfrac{n(n - 3)}{2}: each vertex joins to the n−3n - 3 vertices that are not itself or its neighbors, and each diagonal is counted from both ends.

Step 2 — n(n−3)=40n(n - 3) = 40; try values: n=8n = 8 gives 8⋅5=408\cdot5 = 40.

Step 3 — an octagon.

Side note
Where it goes wrong

Counting grid points instead of steps. A path across a 4×34 \times 3 block of squares has 44 right steps and 33 up steps — (73)\binom73 paths — even though there are 55 columns and 44 rows of intersection points. Count the moves, not the dots.

Try it
Try it: a handshake count

At a party every pair of the 88 guests shakes hands once. How many handshakes?

Show the answer

(82)=28\dbinom82 = 28.

Venn Diagrams and Inclusion–Exclusion

Concept
Add, then subtract the overlap

For two sets, ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|. For three, ∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|.

Why the corrections: ∣A∣+∣B∣|A| + |B| counts everything in the overlap twice, once in each set, so the overlap is subtracted once. With three sets, a point in all three is added three times and subtracted three times, leaving it uncounted — so it is added back once. The Venn diagram shows the same bookkeeping region by region, and filling it from the INSIDE out (triple overlap first) avoids every sign error.

Example
Worked: two teams
30 students1177soccer 18basketball 14neither: 5
Fill the overlap first, then the rest of each circle.

In a class of 3030, 1818 students play soccer, 1414 play basketball, and 77 play both. How many play neither?

Step 1 — at least one sport: 18+14−7=2518 + 14 - 7 = 25.

Step 2 — neither: 30−25=530 - 25 = 5. In the diagram: both 77, soccer only 18−7=1118 - 7 = 11, basketball only 14−7=714 - 7 = 7, and 11+7+7=2511 + 7 + 7 = 25.

Example
Worked: multiples of 3 or 5

How many integers from 11 to 100100 are divisible by 33 or by 55?

Step 1 — multiples of 33: ⌊100/3⌋=33\lfloor 100/3\rfloor = 33; of 55: 2020.

Step 2 — both means divisible by 1515: 66 of them.

Step 3 — 33+20−6=4733 + 20 - 6 = 47.

Example
Worked: three sets
2714713733multiples of 2of 3of 5outside: 26
Every region filled in; the seven inside numbers add to 7474.

How many integers from 11 to 100100 are divisible by 22, 33 or 55?

Step 1 — singles: 50+33+20=10350 + 33 + 20 = 103.

Step 2 — pairs: divisible by 66: 1616; by 1010: 1010; by 1515: 66; subtract 3232.

Step 3 — all three, divisible by 3030: 33; add back.

Step 4 — 103−32+3=74103 - 32 + 3 = 74. So 2626 numbers from 11 to 100100 are divisible by none of 22, 33, 55.

Side note
Where it goes wrong

Forgetting to add back the triple overlap. Stopping at 103−32=71103 - 32 = 71 leaves the numbers 30,60,9030, 60, 90 uncounted: each was added three times and subtracted three times.

Try it
Try it: fruit

In a group of 4040 people, 2525 like apples, 2020 like bananas, and 33 like neither. How many like both?

Show the answer

At least one: 40−3=3740 - 3 = 37. Then 25+20−both=3725 + 20 - \text{both} = 37, so both =8= \mathbf{8}.

Putting It Together

Example
Worked: complement and overlap together

How many integers from 11 to 6060 are divisible by neither 22 nor 33?

Step 1 — complement: count those divisible by 22 or 33 and subtract from 6060.

Step 2 — inclusion–exclusion: 30+20−10=4030 + 20 - 10 = 40 (the 1010 are multiples of 66).

Step 3 — 60−40=2060 - 40 = 20. These are the numbers leaving remainder 11 or 55 on division by 66: two in every block of six, and 6060 is ten blocks.

Tip
Four questions before counting

Does order matter? Is there an "at least" (complement)? Do the categories overlap (inclusion–exclusion)? Is there a parity or pairing that makes the answer immediate? Answer these first and most AMC 8 counting problems become one line.

Try it
Try it: odd digits with a 5

How many three-digit numbers have all digits odd and at least one digit equal to 55?

Show the answer

All digits odd: 53=1255^3 = 125. All odd and no 55 (digits from 1,3,7,91, 3, 7, 9): 43=644^3 = 64. At least one 55: 125−64=61125 - 64 = \mathbf{61}.