We randomly put the keys of the padlocks into the closed padlocks, one each.

We will break open one of the padlocks. What is the probability that after this, we can open all the padlocks without having to break any more?

What is the probability if we initially break open two padlocks?
I. solution. Let's number the lockers and the corresponding keys from 1 to 30, then place the keys in the closed lockers, and line up the lockers. According to the condition, then the 30 keys have 30! equally likely arrangements. We need the number of sequences in which we can pull out a part of the keys, so that we can open all the lockers, meaning we have pulled out all the keys.

In a given arrangement, we will get stuck precisely when the locker whose key we have just picked is already open. The key itself can only be the key to the 1st numbered, broken locker, as the key to an already open locker cannot be in a later locker without using force. Therefore, if we can open all the lockers, then the thirtieth key we pull out is the key to the 1st numbered, broken locker. We call the sequences of keys in the lockers that allow this good sequences.

Now, every possible sequence of key pulls $S=\left(s_{1}, s_{2}, \ldots, s_{30}\right)$ - where $s_{30}=1$ - can be matched to a good sequence $S^{*}=\left(s_{1}^{*}, s_{2}^{*}, \ldots, s_{30}^{*}\right)$ of the keys in the lockers, in which we access the keys in the $S$ sequence. Clearly,

$$
s_{1}^{*}=s_{1}, \quad s_{s_{1}}^{*}=s_{2}, \quad s_{s_{2}}^{*}=s_{3}, \ldots, s_{s_{28}}^{*}=s_{29} \quad s_{s_{29}}^{*}=s_{30}=1
$$

The correspondence $S \leftrightarrow S^{*}$ clearly maps the set of permutations ending in 1 onto the set of good sequences in a one-to-one manner, so there are as many good sequences as there are ways to arrange 30 keys such that the 1st is in the last position. Since the number of such sequences is exactly 29!, the sought probability is $\frac{29!}{30!}=\frac{1}{30}$

In the second case, when we break open two lockers at the beginning - let's assume these are the 1st and 2nd numbered ones - exactly those pull sequences are realizable in which we pull out the 1st or the 2nd numbered key last, thirtieth.

Similarly to the previous, now exactly one and only one suitable arrangement of the keys corresponds to such sequences, so the number of the latter is now $2 \cdot 29!$. In the case of two broken lockers, then $\frac{2 \cdot 29!}{30!}=\frac{2}{30}$ is the value of the sought probability.

II. solution. We will show that if we break open $k$ lockers out of $n$ at the beginning $(1 \leqq k \leqq n)$, then $\frac{k}{n}$ is the probability that we can then open all the lockers.

Let $p_{n, k}$ denote the probability of this event.

It is obvious that $p_{k, k}=1$. Now let $n>k$ and consider the $n$-th locker. If this contains its own key - the probability of which is $1 / n$ - then we cannot access this locker. If the $n$-th locker contains the $i$-th key, and the key to the $n$-th locker is in the $j$-th locker $(1<i, j<n)$, then this arrangement is exactly openable if this is true for the $n-1$ lockers as well, where the $i$-th key is in the $j$-th locker. Since the probability of this is $p_{n-1, k}$, then

$$
\begin{gathered}
p_{n, k}=\left(1-\frac{1}{n}\right) p_{n-1, k}=\left(1-\frac{1}{n}\right)\left(1-\frac{1}{n-1}\right) \ldots\left(1-\frac{1}{k+1}\right) p_{k, k}= \\
=\frac{n-1}{n} \cdot \frac{n-2}{n-1} \cdot \cdots \cdot \frac{k}{k+1}=\frac{k}{n}
\end{gathered}
$$

indeed.