5. Let $n$ and $k$ be positive integers, $k \geqslant n$, and $k-n$ is an even number. $2 n$ lamps are sequentially numbered as $1,2, \cdots, 2 n$, and each lamp can be either "on" or "off". Initially, all lamps are off. An operation can be performed on these lamps: each operation changes the state of one lamp (i.e., on becomes off, off becomes on). Consider a sequence of length $k$, where the $i$-th term of the sequence is the number of the lamp whose state is changed during the $i$-th operation.

Let $N$ be the number of different operation sequences of length $k$ that result in lamps $1,2, \cdots, n$ being on and lamps $n+1, n+2, \cdots, 2 n$ being off after $k$ operations;

Let $M$ be the number of different operation sequences of length $k$ that result in lamps $1,2, \cdots, n$ being on and lamps $n+1, n+2, \cdots, 2 n$ being off, with the condition that lamps $n+1, n+2, \cdots, 2 n$ are never turned on during the operations.
Find the ratio $\frac{N}{M}$.
(France provided)
5. (Zhang Ruixiang's solution) The required ratio is $2^{k-n}$.

Lemma: Let $t$ be a positive integer. If a $t$-element 0,1 array $\left(a_{1}, a_{2}, \cdots, a_{t}\right)\left(a_{1}, a_{2}, \cdots, a_{t} \in\{0,1\}\right)$ contains an odd number of 0s, then it is called "good". The number of good arrays is $2^{t-1}$.

Proof of the lemma: In fact, for the same $a_{1}$, $a_{2}, \cdots, a_{t-1}$, when $a_{t}$ takes 0 and 1, the parity of the two resulting arrays is different, so exactly one of them is good. Thus, the total $2^{t}$ different possible arrays can be paired, with each pair differing only in $a_{t}$, and each pair contains exactly one good array. Therefore, the number of good arrays is half of the total, i.e., $2^{t-1}$.
The lemma is proved.

We denote the set of all operation sequences that result in lights $1,2, \cdots, n$ being on and lights $n+1, n+2, \cdots, 2 n$ being off after $k$ operations as $A$ class sequences; the set of all operation sequences that result in lights $1,2, \cdots, n$ being on and lights $n+1, n+2, \cdots, 2 n$ being off after $k$ operations, and where lights $n+1, n+2, \cdots, 2 n$ are never operated on, as $B$ class sequences.

For any $B$ class sequence $b$, we can correspond all $A$ class sequences $a$ that have the following property: "the elements of $a$ correspond to the same elements modulo $n$" (for example, when $n=2, k=4$, $b=(2,2,2,1)$ can correspond to $a=(4,4,2,1)$, $a=(2,2,2,1)$, $a=(2,4,4,1)$, etc.). Since $b$ is a $B$ class sequence, the number of $1,2, \cdots, n$ in $b$ must all be odd, and $a$ is an $A$ class sequence, so the number of $1,2, \cdots, n$ in $a$ must all be odd, and the number of $n+1, n+2, \cdots, 2 n$ must all be even.

Thus, for any $i \in\{1,2, \cdots, n\}$, let $b$ have $b_{i}$ occurrences of $i$. Then $a$ must and only need to satisfy: for any $i \in\{1,2, \cdots, n\}$, the $b_{i}$ positions in $b$ that are $i$ must be $i$ or $n+i$ in $a$, and $i$ must have an odd number (naturally, $n+i$ will have an even number).

By the lemma and the multiplication principle, $b$ can correspond to
$$
\prod_{i=1}^{n} 2^{b_{i}-1}=2^{k-n}
$$

different $a$s, and each element $a$ in $A$ has a unique element $b$ in $B$ (which is obtained by transforming each element of $a$ to its smallest positive remainder when divided by $n$) that can correspond to it.
Thus, we must have $|A|=2^{k-n}|B|$, i.e.,
$$
N=2^{k-n} M \text {. }
$$

It is also easy to see that $M \neq 0$ (since the operation sequence $(1,2, \cdots, n, n, \cdots, n) \in B)$, then
$$
\frac{N}{M}=2^{k-n} \text {. }
$$