基本计数原理
组合学
Combinatorics is an area of mathematics primarily concerned with counting and certain properties of finite structures.
Combinatorial problems arise in many areas of pure mathematics such as algebra, probability theory, topology, and geometry.
One of the oldest and important area closely related to combinatorics is graph theory.
Combinatorics is used frequently in computer science to obtain formulas and estimates in the analysis of algorithms.
Enumerative combinatorics is the most classical area of combinatorics and concentrates on counting the number of certain combinatorial objects.
Combinatorial principles
Rule of sum
Rule of product
Mathematical induction
Pigeonhole principle
Inclusion–exclusion principle
Generating function
加法原则
Example 1 Candy is wearing her lucky shirt today, and she has to choose among 4 white skirts, 3 black skirts, and 2 red skirts.
How many different choices of one skirt does she have for the day?
Exercise 1 How many integer solutions are there to the following:
-5 < x < 5\quad \text{ or }\quad 12 < x < 100?
乘法原则
Example 2 Kate is trying to decide what to wear.
She has shirts in the following colors: white, blue, and purple.
And she has pants in the following colors: black and grey.
How many different outfits can Kate choose from (assuming she selects one shirt and one pair of pants)?
Exercise 2 How many positive divisors does 800 have?
Exercise 3 There are three cities denoted by A,B,C. There are 3 paths from A to B; 2 paths from B to C, and 4 paths from A to C. How many different ways can Bob choose from A to C?
数学归纳法
Weak induction: The most common form of proof by mathematical induction requires proving in the inductive step that
\forall k(P(n)\to P(n+1)) Strong induction: the statement P(n + 1) holds under the assumption that P(k) holds for all natural k less than n + 1.
Horse paradox
All horses are the same color.
If there is only one horse in the “group”, then clearly all horses in that group have the same color.
Assume that n horses always are the same color. Consider a group consisting of n+1 horses.
First, exclude one horse and look only at the other n horses; all these are the same color since n horses always are the same color.
Likewise, exclude some other horse and look only at the other n horses. These must also be of the same color.
- So, If n horses have the same color, then n+1 horses will also have the same color.
The paradox was presented in 1961 in a satirical article by Joel E. Cohen.
Exercise 4 For all positive integers n , the number of all subsets of [n] (same as \{1,2,\cdots,n\}) is 2^n.
鸽巢原理
Basic version If n objects are distributed over m places, and if n > m, then some place receives at least two objects.
Generalized version Let n, m and r be positive integers so that n > rm. Let us distribute n identical balls into m identical boxes. Then there will be at least one box into which we place at least r + 1 balls.
Example 3 Ten points are given within a square of unit size.
Then there are two of them that are closer to each other than 0.48,
and there are three of them that can be covered by a disk of radius 0.5.
Exercise 5 There is an element in the sequence 7, 77, 777, 7777, \cdots, that is divisible by 2003.
容斥原理
The inclusion–exclusion principle is a counting technique which generalizes the familiar method of obtaining the number of elements in the union of two finite sets.
|A\cup B|=|A|+|B|-|A\cap B|,
|A\cup B\cup C|=|A|+|B|+|C|-|A\cap B|-|A\cap C|-|B\cap C|+|A\cap B\cap C|.
\left|\bigcup _{i=1}^{n}A_{i}\right|=\sum _{i=1}^{n}|A_{i}|-\sum _{1\leqslant i<j\leqslant n}|A_{i}\cap A_{j}|+\sum _{1\leqslant i<j<k\leqslant n}|A_{i}\cap A_{j}\cap A_{k}|-\cdots +(-1)^{n-1}\left|A_{1}\cap \cdots \cap A_{n}\right|.
Example 4 There are 15 students in a high school class who play soccer, and there are 18 students who play basketball. Five students play both games. How many students play at least one of the two games? 15+18-5
Exercise 6 How many positive integers in [105] (\{1,2,\cdots,105\}) that have factor 3 or 5 or 7?
A party was attended by n guests.
When the guests arrived, they left their hats in the same coatroom. After the party ended, there was an electrical power failure, so each guest took a hat from the coatroom at random. When the guests were back on the street, they were amused to find out that none of them got his hat back.
In how many different ways could that happen?
Derangement
Suppose that n persons are numbered 1,2,\cdots,n. Let there be n hats also numbered 1,2,\cdots,n. We have to find the number of ways in which no one gets the hat having same number as his/her number.
Let A_i be the set of all permutations of [n] in which the element i is in the ith position, in other words, in which the element i is fixed.
For example, 23541\in A_4.
The answer is connected with \#(\bigcup _{i=1}^{n}A_{i}).
\#A_i=(n-1)!
The set A_i\cap A_j consists of permutations in which elements i and j are fixed, and the remaining n-2 entries can be permuted freely, in (n-2)! ways. \#(A_i\cap A_j)=(n-2)!
We save the rest for later.