Double Counting Notes by Victoria Krakovna
by SomeonecoolLovesMaths, Mar 12, 2025, 2:46 PM
In many combinatorics problems, it is useful to count a quantity in two ways. Let’s start with a simple example.
(Iran 2010 \#2) There are
points in the plane such that no three of them are collinear. Prove that the number of triangles, whose vertices are chosen from these
points and whose area is
, is not greater than
.
Let the number of such triangles be
. For each edge between two points in the set we count the number of triangles it is part of. Let the total number over all edges be
.
On the one hand, for any edge
, there are at most
points such that the triangles they form with
and
have the same area. This is because those points have to be the same distance from line
, and no three of them are collinear. Thus,
. On the other hand, each triangle has
edges, so
. Thus,
![\[
k \leq \frac{T}{3} \leq \frac{4}{3} \binom{n}{2} = \frac{2}{3}(n^2 - n).
\]](//latex.artofproblemsolving.com/5/7/5/57549da7e5a31d84d6c9ed82afd51b5f57f68e75.png)
It’s a good idea to consider double counting if the problem involves a pairing like students and committees, or an array of numbers; it’s also often useful in graph theory problems.
(IMO 1987 #1) Let
be the number of permutations of the set
which have exactly
fixed points. Prove that
![\[
\sum_{k=0}^{n} k \cdot p_n(k) = n!.
\]](//latex.artofproblemsolving.com/5/a/3/5a33870a43bd98f6e60b2a4df907ca0cb3675435.png)
The first idea that might occur here would be to find
, then multiply it by
, sum it up… probably resulting in a big expression. However, if we look at the required result, we see that it suggests a natural counting — the left-hand side is the total number of fixed points over all permutations. Another way to obtain that is to consider that each element of
is a fixed point in
permutations, so the total is
. (Note that we are counting pairs of the form (point, permutation) such that the point is a fixed point of the permutation.) 

(China Hong Kong MO 2007) In a school there are 2007 girls and 2007 boys. Each student joins no more than 100 clubs in the school. It is known that any two students of opposite genders have joined at least one common club. Show that there is a club with at least 11 boys and 11 girls.
Since we are only given information about club membership of students of different gender, this suggests that we should consider triples of the form (boy, girl, club), where the boy and girl both attend the club. Let the total number of such triples be
.
For each pair (boy, girl), we know that they attend at least one club together, so since there are
such pairs,
![\[
T \ge 2007^2 \cdot 1.
\]](//latex.artofproblemsolving.com/9/a/4/9a40daed5003e91e392e6a9a5f0c7ed0eb7de53e.png)
Assume that there is no club with at least 11 boys and 11 girls. Let
be the number of triples involving clubs with at most 10 boys, and
be the number of triples involving clubs with at most 10 girls. Since any student is in at most 100 clubs, the number of (girl, club) pairs is at most
, so
. Similarly,
. Then,
which is a contradiction. 
If
is an integer and
is a prime, then
![\[
a^p \equiv a \pmod{p}.
\]](//latex.artofproblemsolving.com/9/a/d/9adaf16e16bc3b65a4dd4930d8e6975955e70b24.png)
Consider the set of strings of length
using an alphabet with
different symbols. Note that these strings can be separated into equivalence classes, where two strings are equivalent if they are rotations of each other. Here is an example of such an equivalence class (called a "necklace") for
:
![\[
\{ \text{BCCCB}, \text{CCBCB}, \text{CBBCC}, \text{BBCCC}, \text{CCCBB} \}.
\]](//latex.artofproblemsolving.com/5/f/5/5f5c655e300391e559515243b47f46e3f6a408ec.png)
Let’s call a string with at least two distinct symbols in it \textit{non-trivial}. All the rotations of a non-trivial string are distinct — since
is prime, a string cannot consist of several identical substrings of size greater than
. Thus, all the equivalence classes have size
, except for those formed from a trivial string, which have size
.
Thus, there are two ways to count the number of non-trivial strings. Since there are
strings in total,
of which are trivial, we have
non-trivial strings. Also, the number of non-trivial strings is
times the number of equivalence classes formed by non-trivial strings. Therefore,
divides
. 
might contain mistakes








On the one hand, for any edge








![\[
k \leq \frac{T}{3} \leq \frac{4}{3} \binom{n}{2} = \frac{2}{3}(n^2 - n).
\]](http://latex.artofproblemsolving.com/5/7/5/57549da7e5a31d84d6c9ed82afd51b5f57f68e75.png)
It’s a good idea to consider double counting if the problem involves a pairing like students and committees, or an array of numbers; it’s also often useful in graph theory problems.




![\[
\sum_{k=0}^{n} k \cdot p_n(k) = n!.
\]](http://latex.artofproblemsolving.com/5/a/3/5a33870a43bd98f6e60b2a4df907ca0cb3675435.png)











For each pair (boy, girl), we know that they attend at least one club together, so since there are

![\[
T \ge 2007^2 \cdot 1.
\]](http://latex.artofproblemsolving.com/9/a/4/9a40daed5003e91e392e6a9a5f0c7ed0eb7de53e.png)
Assume that there is no club with at least 11 boys and 11 girls. Let





![\[
2007^2 \le T \le X + Y \le 2 \cdot 2007 \cdot 1000 = 2007 \cdot 2000
\]](http://latex.artofproblemsolving.com/8/8/7/8874e043afee1a11735de033e2f40cfd9802c6e5.png)




![\[
a^p \equiv a \pmod{p}.
\]](http://latex.artofproblemsolving.com/9/a/d/9adaf16e16bc3b65a4dd4930d8e6975955e70b24.png)




![\[
\{ \text{BCCCB}, \text{CCBCB}, \text{CBBCC}, \text{BBCCC}, \text{CCCBB} \}.
\]](http://latex.artofproblemsolving.com/5/f/5/5f5c655e300391e559515243b47f46e3f6a408ec.png)
Let’s call a string with at least two distinct symbols in it \textit{non-trivial}. All the rotations of a non-trivial string are distinct — since




Thus, there are two ways to count the number of non-trivial strings. Since there are







might contain mistakes