You are on page 1of 4

Counting In Two Ways

January 25, 2016

Introduction

It is often very useful and rewarding (especially if you consider a 7/7 as a reward)
to count a quantity in two ways. This method provides us an efficient method
to bound the size and sometimes even find the values of unknown quantities. It
also has a few remarkable applications, which we shall see shortly. This is what
you basically do in double counting: Pick a quantity, count it up in two ways,
and hence compare the expressions so obtained. This is sometimes useful even
in proving the existence of some objects. There doesnt seem to be anything
more that I would like to put in this section, so lean back, have a nice warm
cup of tea, and .... enjoy.

Double Counting - Illustrations

Okay, so in this section you shall find problems which shall neither be trivial
nor hard. If you are already well-versed in this topic, then go ahead and try
these out as problems. We start with a relatively simple example:
1. (Iran 2010) There are n points in the plane such that no three of them are
collinear. Prove that the number of triangles, whose vertices are chosen from
these n points and whose area is 1, is not greater than 23 (n2 n).
Solution. () Let the number of such triangles be k. 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 T . On the one hand, for any edge AB, there are
at most 4 points such that the triangles they form with A and B have the same
area. This is because those points have to be the same
distance from line AB,

and no three of them are collinear. Thus, T 43 n2 . On the other hand, each
triangle has 3 edges so T 3k. These two together imply the required result.
Just a few things to keep in mind while applying this technique:
i. Try counting ordered pairs or triples or n-tuples satisfying certain conditions. They will often help you kill the problem
ii. If you wish to bound an unknown quantity, say, x, then set up the doublecount in such a way that one of the ways of coutning involves x, while the other
doesnt.
2. (IMO Shortlist 2004) There are 10001 students at a university. Some students
1

join together to form several clubs (a student may belong to different clubs).
Some clubs join together to form several societies (a club may belong to different
societies). There are a total of k societies. Suppose that the following conditions
hold:
(i) Each pair of students is in exactly one club.
(ii) For each student and each society, the student is in exactly one club of
the society.
(iii) Each club has an odd number of students. In addition, a club with
2m + 1 students (m is a positive integer) is in exactly m societies.
Find all possible values of k.
Solution. Let us double-count the number of triples of the form (s, C, S) where
s is a student, C is a community, S is a society, and s C, C S. Let the
number of such triples be k. Suppose we fix s, then S then C. Thus we find
k = 10001 n, where n is the number of
Now,
 suppose we fix C, then
Psocieties.
a
=
S then s. We get that k is equal to
a a1
2 , where the sum is over
2
all clubs, and a denotes the number of members of the particular club. On the
other hand, due to condition (i), another simple double-count shows that this
sum is equal to the number of pairs of students, which is equal to 5000 10001.
Hence k = 5000 is the only possible value of k.
Now, to show that this value works, take only one club having all students
and 5000 societies having this club.
We now leave a few problems for the readers.
1. (USA TST 2005) Let n be an integer greater than 1. For a positive integer
m, let Sm = {1, 2, ..., mn}. Suppose that there exists a 2n-element set T such
that
(a) each element of T is an m-element subset of Sm ,
(b) each pair of elements of T shares at most one common element; and
(c) each element of Sm is contained in exactly two elements of T .
Determine the maximum possible value of m in terms of n.
2. (IMO 1987) Let pn (k) be the number of permutations of the set {1, 2, ..., n}
which have exactly k fixed points. Prove that
n
P

kpk (n) = n!.

k=0

3. (Hong Kong 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.
4. (IMO 1998) In a competition, there are a contestants and b judges, where
b 3 is an odd integer. Each judge rates a contestant as either pass or fail.
Suppose k is a number such that for any two judges, their ratings coincide for
at most k contestants. Prove that ka b1
2b .
5. (APMO 1989) Show that a graph on n vertices and k edges has at least
k(4kn2 )
triangles.
3n
6. (USAMO 1995) Suppose that in a certain society, each pair of persons can

be classified as either amicable or hostile. We shall say that each member of an

amicable pair is a friend of the other, and each member of a hostile pair is a
foe of the other. Suppose that the society has n people and q amicable pairs,
and that for every set of three persons, at least one pair is hostile. Prove that
there is at least one member of the society whose foes include q(1 n4q2 ) or fewer
amicable pairs.

Some Cool Proofs Using Double Counting

We start with a problem that is simply amazing. We borrow its solution and
motivation from .
1. (IMO Shortlist 2003/C4) Let x1 , x2 , ..., xn and y1 , y2 , ..., yn be real numbers.
Let A = {aij } (with 1 i, j n) be an n n matrix with entries aij = 1 if
xi + yj 0, and aij = 0 otherwise.
Let B be an n n matrix with entries 0 or 1 such that the sum of elements
of each row and each column of B equals the corresponding sum for matrix A.
Show that A = B.
Solution. () Let bij denote the entry in the i-th row and j-th column of B.
Define
P
S=
(aij bij )(xi + yi ).
1i,jn

On one hand, S =

n
P
i=1

xi (

n
P

aij

j=1

n
P

bij ) +

j=1

n
P
j=1

yi (

n
P
i=1

aij

n
P

bij ) = 0 by the

i=1

conditions of the problem.

On the other hand, note that if xi + yj 0 then aij = 1 so aij bij 0. If
xi + yj < 0 then aij = 0 so aij bij 0. In both cases, (xi + yj )(aij bij ) 0.
But the total sum S is 0, so whenever xi + yj 6= 0 we have aij = bij . Whenever
xi + yj = 0, aij = 1. In these cases we must have bij = 1 as well, as the sums
of entries in both matrices is the same. This completes the solution.
Motivation. () Where on earth does the expression
P
S=
(aij bij )(xi + yi ).
1i,jn

come from?!?! Note that one way of proving that several different real numbers
are 0 is to show that their squares sum to 0, since no square is negative. Thus,
a first approach to the problem may be to show that the sum
P
S0 =
(aij bij )2
1i,jn

is zero. This doesnt work as it doesnt utilize information about the xs and
ys. Instead we try the following modification: we seek to weight each term
by some other quantity that still ensures that each term in the summation is
nonnegative, and additionally enables us to use the information about the xs
and ys to show that the entire sum is 0.
3

The rest are left as problems for the reader:

1. (Cayleys Formula) The number of different unrooted trees that can be
formed from a set of n distinct vertices is Tn = nn2 .
2. (Fermats Little Theorem!!!!) If a is an integer and p is a prime, then
ap a(mod p).
3. (IMO 2001) Let n be an odd positive integer greater than 1 and let c1 , c2 , ..., cn
be integers. For each permutation a = {a1 , ..., an } of {1, 2, ..., n}, define S(a) =
n
P
ai ci . Prove that there exist permutations a 6= b such that n! is a divisor of
i=1

S(a) S(b).

References