12. (1998 China National Team Selection Test for IMO) For a fixed $\theta \in\left(0, \frac{\pi}{2}\right)$, find the smallest positive number satisfying the following two conditions:
(i) $\frac{\sqrt{a}}{\cos \theta}+\frac{\sqrt{a}}{\sin \theta}>1$;
(ii) There exists $x \in\left[1-\frac{\sqrt{a}}{\sin \theta}, \frac{\sqrt{a}}{\cos \theta}\right]$, such that
$$
\left[(1-x) \sin \theta-\sqrt{a-x^{2} \cos ^{2} \theta}\right]^{2}+\left[x \cos \theta-\sqrt{a-(1-x)^{2} \sin ^{2} \theta}\right]^{2} \leqslant a .
$$
12. From (i) we get
$$
\sqrt{a}>\frac{\sin \theta \cos \theta}{\sin \theta+\cos \theta},
$$

Without loss of generality, assume $\frac{a}{\sin ^{2} \theta}+\frac{a}{\cos ^{2} \theta} \leqslant 1$.
(ii) is equivalent to: there exists $x \in\left[1-\frac{\sqrt{a}}{\sin \theta}, \frac{\sqrt{a}}{\cos \theta}\right]$, such that $2(1-x) \sin \theta \sqrt{a-x^{2} \cos ^{2} \theta}+2 x \cos \theta \sqrt{a-(1-x)^{2} \sin ^{2} \theta} \geqslant a$, i.e., $2 \sin \theta \cos \theta\left[(1-x) \sqrt{\frac{a}{\cos ^{2} \theta}-x^{2}}+x \sqrt{\frac{a}{\sin ^{2} \theta}-(1-x)^{2}}\right] \geqslant u$.
First, we prove a lemma: Let $o1, p^{2}+q^{2} \leqslant 1, f(x)=(1-x) \sqrt{p^{2}-x^{2}}+$ $x \sqrt{q^{2}-(1-x)^{2}}(1-q \leqslant x \leqslant p)$, then when $\sqrt{p^{2}-x^{2}}=\sqrt{q^{2}-(1-x)^{2}}$, i.e., $x=\frac{p^{2}-q^{2}+1}{2} \in[1-q, p]$, $f(x)$ reaches its maximum value.
Proof of the lemma: Since $1-q \leqslant x \leqslant p$, we can let
$x=p \sin \alpha, 1-x=q \sin \beta, 00$,
The roots of the left side of (4) are
$$
\begin{aligned}
& \frac{\sin ^{1} \theta \cos ^{1} \theta}{1-3 \sin ^{2} \theta \cos ^{1} \theta}\left[\frac{1}{\cos ^{2} \theta}+\frac{1}{\sin ^{2} \theta} \pm \sqrt{\left(\frac{1}{\cos ^{2} \theta}+\frac{1}{\sin ^{2} \theta}\right)^{2}-\frac{1}{\cos ^{1} \theta}-\frac{1}{\sin ^{1} \theta}+\frac{1}{\sin ^{2} \theta \cos ^{2} \theta}}\right] \\
= & \frac{\sin ^{2} \theta \cos ^{2} \theta}{1 \mp \sqrt{3} \sin \theta \cos \theta},
\end{aligned}
$$

Therefore, from (4) we get
$$
\frac{\sin ^{2} \theta \cos ^{2} \theta}{1+\sqrt{3} \sin \theta \cos \theta} \leqslant a \leqslant \frac{\sin ^{2} \theta \cos ^{2} \theta}{1-\sqrt{3} \sin \theta \cos \theta} .
$$

Since $\frac{\sin ^{2} \theta \cos ^{2} \theta}{(\sin \theta+\cos \theta)^{2}}<\frac{\sin ^{2} \theta \cos ^{2} \theta}{1+\sqrt{3} \sin \theta \cos \theta}$,
Therefore, when
$a=\frac{\sin ^{2} \theta \cos ^{2} \theta}{1+\sqrt{3} \sin \theta \cos \theta}$, (1) is satisfied, hence the required
$$
a=\frac{\sin ^{2} \theta \cos ^{2} \theta}{1+\sqrt{3} \sin \theta \cos \theta} .
$$