4. There is a 1001-digit natural number $A$. The 1001-digit number $Z$ is the same number $A$, written from end to beginning (for example, for four-digit numbers, these could be 7432 and 2347). It is known that $A > Z$. For which $A$ will the quotient $A / Z$ be the smallest (but strictly greater than 1)?
Answer. For $A$, whose notation (from left to right) is: 501 nines, an eight, and 499 nines.

Solution 1. Let $A=\overline{a_{1000} a_{999 \ldots a_{0}}}$. Since $A>Z$, among the digits $a_{0}, a_{1}, \ldots, a_{499}$ there is at least one non-nine. Therefore, $Z \leqslant Z_{0}=\underbrace{99 \ldots 9}_{499} 8 \underbrace{99 \ldots 9}_{501}$.

We will show that $A-Z \geqslant 10^{501}-10^{499}$. From this it will follow that

$$
\frac{A}{Z}-1 \geqslant \frac{10^{501}-10^{499}}{Z_{0}}
$$

this estimate is achieved when $Z=Z_{0}$, which gives the answer.

We have

$$
\begin{aligned}
A-Z & =\left(a_{1000}-a_{0}\right)\left(10^{1000}-1\right)+\left(a_{999}-a_{1}\right)\left(10^{999}-10\right)+\cdots+\left(a_{501}-a_{499}\right)\left(10^{501}-10^{499}\right)= \\
& =\varphi_{499} \Delta_{499}+\varphi_{498} \Delta_{498}+\cdots+\varphi_{0} \Delta_{0}
\end{aligned}
$$

where $\varphi_{i}=a_{501+i}-a_{499-i}$ and $\Delta_{i}=10^{501+i}-10^{499-i}$ for $i=0,1, \ldots, 499$. Note that $\Delta_{i+1}>10 \Delta_{i}$.

Let $j$ be the largest index for which $\varphi_{j} \neq 0$. Then

$$
\begin{aligned}
\left|\varphi_{j} \Delta_{j}+\varphi_{j-1} \Delta_{j-1}+\cdots+\varphi_{0} \Delta_{0}\right| & \geqslant\left|\varphi_{j} \Delta_{j}\right|-\left|\varphi_{j-1} \Delta_{j-1}\right|-\cdots-\left|\varphi_{0} \Delta_{0}\right| \geqslant \\
& \geqslant \Delta_{j}\left(1-\frac{9}{10}-\frac{9}{100}-\cdots-\frac{9}{10^{j}}\right)=\frac{\Delta_{j}}{10^{j}} \geqslant \Delta_{0}
\end{aligned}
$$

which is what we needed.

Solution 2. It is clear that we can minimize (the positive) number $\frac{A}{Z}-1=\frac{A-Z}{Z}$.

Number the digits in $A$ from left to right as $a_{1}, a_{2}, \ldots, a_{1001}$. Let $k$ be the smallest index for which $a_{k} \neq a_{1002-k}$ (then $k \leqslant 500$ and $a_{k}>a_{1002-k}$, since $A>Z$).

Consider an arbitrary optimal example. Replace the first and last $k-1$ digits with nines. $A-Z$ will not change, and $Z$ will not decrease, so our fraction will not increase. For the same reason, $a_{501}$ can be replaced with 9.

Replace $a_{k}$ with 9 and $a_{1002-k}$ with 8. In this case, $A-Z$ will not increase, and $Z$ will not decrease.

Replace all digits $a_{k+1}, \ldots, a_{500}$ with zeros, and $a_{502}, \ldots, a_{1001-k}$ with nines. Then $A-Z$ will not increase, and $Z$ will not decrease (this will only happen if the second half was already nines!). Since in the optimal example $A-Z<Z$ (simply fewer digits), it is clear that $\frac{A-Z}{Z}$ will not increase.

Thus, we can assume that $A$ has the form

$$
\underbrace{99 \ldots 9}_{k} \underbrace{00 \ldots 0}_{500-k} 9 \underbrace{99 \ldots 9}_{500-k} 8 \underbrace{99 \ldots 9}_{k-1} .
$$

In this case,

$$
A-Z=10^{501}+10^{500}-10^{k}-10^{k-1}
$$

This expression reaches its minimum when $k=500$, and for this same $k$, the maximum value of the considered $Z$ is achieved. Therefore, this is the answer.