IMO 2008 · Problem 5

Let \(n\) and \(k\) be positive integers with \(k \geq n\) and \(k-n\) an even number. Let \(2n\) lamps labelled \(1,2,\ldots,2n\) be given, each of which can be either on or off. Initially all the lamps are off. We consider sequences of steps: at each step one of the lamps is switched (from on to off or from off to on).

Let \(N\) be the number of such sequences consisting of \(k\) steps and resulting in the state where lamps \(1\) through \(n\) are all on, and lamps \(n+1\) through \(2n\) are all off.

Let \(M\) be the number of such sequences consisting of \(k\) steps, resulting in the state where lamps \(1\) through \(n\) are all on, and lamps \(n+1\) through \(2n\) are all off, but where none of the lamps \(n+1\) through \(2n\) is ever switched on.

Determine the ratio \(N/M\).

Official text of the problem. Official problem paper (PDF)

Answer

\[ \boxed{\frac{N}{M}=2^{\,k-n}}. \]

Solution

Represent a sequence of steps by a word of length \(k\), whose entries are the labels of the lamps switched. Since all lamps are initially off, a lamp finishes on if and only if its label occurs an odd number of times.

Consequently, \(N\) counts the words in which each label \(1,\ldots,n\) occurs an odd number of times and each label \(n+1,\ldots,2n\) occurs an even number of times. The additional restriction defining \(M\) means that no label greater than \(n\) may occur: its first occurrence would switch that lamp on. Thus \(M\) counts the words using only \(1,\ldots,n\), each occurring an odd number of times.

Map every word counted by \(N\) to a word counted by \(M\) by replacing each label \(n+i\) by \(i\), for \(1\leq i\leq n\). This indeed gives a word counted by \(M\), because the new number of occurrences of \(i\) is the sum of an odd number and an even number.

We show that every word counted by \(M\) has exactly \(2^{k-n}\) preimages. Fix such a word, and let \(r_i\) be its number of occurrences of \(i\). Then each \(r_i\) is positive and odd, and \[ r_1+\cdots+r_n=k. \]

To construct a preimage, we must decide which occurrences of \(i\) to replace by \(n+i\). The number replaced must be even; because \(r_i\) is odd, this also ensures that an odd number of occurrences of \(i\) remain.

There are exactly \(2^{r_i-1}\) ways to make this choice: decide freely whether to replace each of the first \(r_i-1\) occurrences, after which the choice for the last occurrence is uniquely determined by the requirement that the total number replaced be even. The choices for different labels are independent. Hence the number of preimages is \[ \prod_{i=1}^{n}2^{r_i-1} =2^{(r_1+\cdots+r_n)-n} =2^{k-n}. \] Therefore \[ N=2^{k-n}M. \]

Finally, \(M>0\): switch each of lamps \(1,\ldots,n\) once, then switch lamp \(1\) another \(k-n\) times. Since \(k-n\) is nonnegative and even, this is a sequence counted by \(M\). Division by \(M\) proves the stated answer.

The solution was checked against the official IMO shortlist solutions.