Question:
Define two subsets $A$, $B$ of the set of complex numbers $\Bbb C$ as follows:\[  \begin{aligned} A &= \left\{ z \in \Bbb C \, \left| \, z = r \textup{e}^{\textup{i}\theta} , \, r \geqslant 0, \, \theta \in \left[ 0, \frac{\pi}{41}\right]\right.\right\}, \ B &= \left\{ z \in \Bbb C \, \left| \,  z = x + \textup{i}y, \, x,y \in \Bbb R , \, \left| x - y \right| < 2025 \right. \right\} \end{aligned}\]where $\textup{i}$ is the imaginary unit and $r \textup{e}^{\textup{i}\theta} = r \left( \cos \theta + \textup{i} \sin \theta \right)$.
Find all univariate polynomials of complex coefficients $P(x)$, such that for all $z \in A$, we have $P(z) \in B$. (Note: A monomial is also considered a polynomial.)

We determine all polynomials \(P(x)\) with complex coefficients such that
\[
\forall z \in A \; : \; P(z) \in B,
\]
where
\[
A = \bigl\{z = r e^{\mathrm{i}\theta}\;\big|\; r\ge 0,\; \theta\in[0,\tfrac{\pi}{41}]\bigr\}, \qquad
B = \bigl\{z = x+\mathrm{i} y \;\big|\; x,y\in\mathbb R,\; |x-y|<2025\bigr\}.
\]

---

### 1. Constant polynomials

If \(P\) is constant, say \(P(z)=c\) for all \(z\), then the condition reduces to \(c\in B\), i.e.
\[
|\operatorname{Re}(c)-\operatorname{Im}(c)|<2025.
\]
All such constants clearly satisfy the requirement.

---

### 2. Non‑constant polynomials cannot work

Assume, for contradiction, that a non‑constant polynomial \(P\) satisfies the condition.
Let \(\deg P = n \ge 1\) and write
\[
P(z)=a_n z^n + Q(z), \qquad a_n\neq 0,
\]
where \(Q\) is a polynomial of degree at most \(n-1\).

For \(z\in A\) we write \(z = r e^{\mathrm{i}\theta}\) with \(r\ge0\) and \(\theta\in[0,\pi/41]\).
Define the real‑valued function
\[
F(z)=\operatorname{Re}\bigl(P(z)\bigr)-\operatorname{Im}\bigl(P(z)\bigr).
\]
The condition becomes \(|F(z)|<2025\) for every \(z\in A\).

Substituting the expression of \(P\),
\[
F(z)=\operatorname{Re}(a_n z^n)-\operatorname{Im}(a_n z^n) + \bigl(\operatorname{Re}(Q(z))-\operatorname{Im}(Q(z))\bigr).
\]
Because \(\deg Q\le n-1\), there exists a constant \(C>0\) such that for all \(r\ge1\) and all \(\theta\)
\[
\bigl|\operatorname{Re}(Q(z))-\operatorname{Im}(Q(z))\bigr|\le C\, r^{n-1}.
\]

Write \(a_n = |a_n| e^{\mathrm{i}\gamma}\). Then
\[
a_n z^n = |a_n|\, r^n e^{\mathrm{i}(\gamma+n\theta)},
\]
and therefore
\[
\operatorname{Re}(a_n z^n)-\operatorname{Im}(a_n z^n)
   = |a_n|\, r^n \bigl(\cos(\gamma+n\theta)-\sin(\gamma+n\theta)\bigr).
\]
Denote
\[
g(\theta)=\cos(\gamma+n\theta)-\sin(\gamma+n\theta).
\]

For a fixed \(\theta_0\in[0,\pi/41]\), as \(r\to\infty\) we have
\[
F(r e^{\mathrm{i}\theta_0}) = |a_n|\, r^n\, g(\theta_0) + O(r^{n-1}).
\]

If \(g(\theta_0)\neq 0\), then the term \(|a_n|\, r^n |g(\theta_0)|\) dominates the \(O(r^{n-1})\) term, so for sufficiently large \(r\) we obtain
\(|F(r e^{\mathrm{i}\theta_0})|>2025\), contradicting the hypothesis.
Consequently we must have
\[
g(\theta)=0 \qquad\text{for every } \theta\in[0,\pi/41]. \tag{1}
\]

Now \(g(\theta)\) is a real‑analytic (in fact, trigonometric) function of \(\theta\).
If it vanishes on an interval, the identity theorem for analytic functions forces it to vanish identically on \(\mathbb R\):
\[
\cos(\gamma+n\theta)=\sin(\gamma+n\theta)\quad \forall\,\theta\in\mathbb R. \tag{2}
\]

We show that (2) is impossible when \(n\ge 1\).
Indeed, taking \(\theta=0\) gives \(\cos\gamma=\sin\gamma\).
Taking \(\theta=\frac{\pi}{2n}\) (which is allowed because (2) holds for all real \(\theta\)) gives
\[
\cos\Bigl(\gamma+\frac{\pi}{2}\Bigr)=\sin\Bigl(\gamma+\frac{\pi}{2}\Bigr)
\quad\Longrightarrow\quad -\sin\gamma = \cos\gamma.
\]
Together with \(\cos\gamma=\sin\gamma\) this yields \(\sin\gamma=-\sin\gamma\), hence \(\sin\gamma=0\), and then also \(\cos\gamma=0\).
But \(\cos\gamma\) and \(\sin\gamma\) cannot both be zero. This contradiction shows that \(n\) cannot be positive.

Therefore our assumption \(n\ge1\) is false, and any polynomial satisfying the condition must be constant.

---

### 3. Conclusion

The only polynomials \(P(x)\) with complex coefficients such that \(P(z)\in B\) for all \(z\in A\) are the constant polynomials whose value lies in \(B\):
\[
\boxed{\bigl\{\, P(x)=c \;\big|\; c\in\mathbb C,\; |\operatorname{Re}(c)-\operatorname{Im}(c)|<2025 \,\bigr\}}.
\]

---


Question:
Let $ABCD$ be an convex quadrilateral inscribed in a circle with center $O$ and radius $1$, with vertices labeled consecutively around the circle (regardless of orientation), which satisfies $\angle ABC < \angle BCD < 90^\circ$. Let lines $BA$ and $CD$ intersect at $P$, diagonals $AC$ and $BD$ intersect at $Q$. There is a point $K$ on segment $\overline{BC}$, such that $P$, $A$, $K$, $D$ are concyclic and $KB \cdot KC = \frac 12 OP^2$. The perpendicular to $BC$ through $Q$ intersects line $OP$ at $T$.
(1) Find all possible values of $\overline{OP}$.
(2) Find all possible values of $\overline{TB} + \overline{TC}$.

We solve the problem using a convenient coordinate system.

---

### 1. Coordinates and parameters

Place the circumcircle \(\Gamma\) with centre \(O=(0,0)\) and radius \(1\).
Rotate the figure so that chord \(BC\) is vertical and symmetric about the \(x\)-axis.
Write

\[
B = (a,\;b),\qquad C = (a,\;-b),
\]

where \(a = \cos\beta>0,\; b = \sin\beta>0\) and \(a^2+b^2=1\).

Let \(K\) be on segment \(BC\) and set

\[
s = \frac{BK}{BC}\in(0,1).
\]

Since \(B\) has \(y=b\), \(C\) has \(y=-b\), the coordinate of \(K\) is

\[
K = (a,\;b(1-2s)).
\]

Then

\[
KB = 2s b,\qquad KC = 2(1-s)b,
\]

so that

\[
KB\cdot KC = 4b^2 s(1-s). \tag{1}
\]

Denote \(OP = r>0\). The given condition \(KB\cdot KC = \frac12\,OP^2\) yields

\[
4b^2 s(1-s) = \frac{r^2}{2}\quad\Longrightarrow\quad 8b^2 s(1-s)=r^2. \tag{2}
\]

The power of \(K\) with respect to \(\Gamma\) gives

\[
\operatorname{Pow}_\Gamma(K)=OK^2-1 = -KB\cdot KC = -\frac{r^2}{2},
\]

hence

\[
OK^2 = 1-\frac{r^2}{2}. \tag{3}
\]

From the coordinates,

\[
OK^2 = a^2 + b^2(1-2s)^2 = 1 - 4b^2 s(1-s),
\]

which is consistent with (2) and (3).

---

### 2. The concyclicity condition and a linear function

Let \(\omega\) be the circle through \(P,A,K,D\). Define

\[
L(X)=\operatorname{Pow}_\Gamma(X)-\operatorname{Pow}_\omega(X).
\]

Because the equations of both circles contain the same quadratic terms \(x^2+y^2\), \(L\) is an affine linear function: \(L(X)=ux+vy+w\).

Since \(K\in\omega\), \(\operatorname{Pow}_\omega(K)=0\), and (3) gives

\[
L(K)=\operatorname{Pow}_\Gamma(K)=-\frac{r^2}{2}. \tag{4}
\]

Because \(K\) lies on \(BC\), it can be written as the affine combination

\[
K = (1-s)B + sC.
\]

By linearity of \(L\),

\[
L(K) = (1-s)L(B)+sL(C). \tag{5}
\]

We now compute \(L(B)\) and \(L(C)\).

---

### 3. Computing \(L(B)\) and \(L(C)\)

Points \(P,A,B\) are collinear. Choose a coordinate on line \(BP\) with origin at \(P\) and positive direction towards \(B\). Let

\[
PB = d_B>0,\qquad PA = d_A>0.
\]

From the order in a convex quadrilateral (as will be justified later) we have \(P\!-\!A\!-\!B\); thus \(0<d_A<d_B\).

The power of \(P\) with respect to \(\Gamma\) is

\[
p = \operatorname{Pow}_\Gamma(P)=OP^2-1 = r^2-1 = d_A d_B. \tag{6}
\]

Now consider point \(B\). The line \(BP\) meets \(\omega\) at \(P\) and \(A\), therefore

\[
\operatorname{Pow}_\omega(B) = BA\cdot BP,
\]

where the distances are signed according to the same orientation (from \(B\) towards \(P\) as positive). In our coordinate from \(P\),

\[
BA = d_A - d_B,\qquad BP = -d_B,
\]

so

\[
BA\cdot BP = (d_A-d_B)(-d_B) = d_B^2 - d_A d_B = PB^2 - p.
\]

Thus

\[
\operatorname{Pow}_\omega(B)= PB^2 - p.
\]

Because \(\operatorname{Pow}_\Gamma(B)=0\), we obtain

\[
L(B)=0 - \operatorname{Pow}_\omega(B) = p - PB^2. \tag{7}
\]

An identical argument for point \(C\) yields

\[
L(C) = p - PC^2. \tag{8}
\]

---

### 4. A key relation involving \(PB^2\) and \(PC^2\)

Substitute (4), (7), (8) into (5):

\[
-\frac{r^2}{2} = (1-s)(p-PB^2)+s(p-PC^2) = p - \bigl[(1-s)PB^2+s\,PC^2\bigr].
\]

Hence

\[
(1-s)PB^2+s\,PC^2 = p + \frac{r^2}{2}
= (r^2-1)+\frac{r^2}{2} = \frac{3r^2-2}{2}. \tag{9}
\]

---

### 5. Express \(PB^2\), \(PC^2\) in coordinates

Write \(P\) in polar form: \(P = (r\cos\varphi,\;r\sin\varphi)\). Using the coordinates of \(B\) and \(C\),

\[
PB^2 = r^2+1-2r\cos(\varphi-\beta),\qquad
PC^2 = r^2+1-2r\cos(\varphi+\beta). \tag{10}
\]

Insert (10) into (9). The sum \((1-s)(r^2+1)+s(r^2+1)=r^2+1\) cancels, leaving

\[
-2r\bigl[(1-s)\cos(\varphi-\beta)+s\cos(\varphi+\beta)\bigr] = \frac{3r^2-2}{2} - (r^2+1) = \frac{3r^2-2-2r^2-2}{2} = \frac{r^2-4}{2}.
\]

Thus

\[
(1-s)\cos(\varphi-\beta)+s\cos(\varphi+\beta) = \frac{4-r^2}{4r}. \tag{11}
\]

Expanding the left‑hand side:

\[
\cos(\varphi-\beta) = \cos\varphi\cos\beta + \sin\varphi\sin\beta,\qquad
\cos(\varphi+\beta) = \cos\varphi\cos\beta - \sin\varphi\sin\beta,
\]

gives

\[
(1-s)\cos(\varphi-\beta)+s\cos(\varphi+\beta) = \cos\beta\cos\varphi + (1-2s)\sin\beta\sin\varphi. \tag{12}
\]

Hence (11) becomes

\[
\cos\beta\cos\varphi + (1-2s)\sin\beta\sin\varphi = \frac{4-r^2}{4r}. \tag{13}
\]

---

### 6. Application of Cauchy‑Schwarz and determination of \(OP\)

The left side of (13) is the dot product of the vectors

\[
\mathbf{u}=(\cos\beta,\;(1-2s)\sin\beta),\qquad \mathbf{v}=(\cos\varphi,\sin\varphi).
\]

Note that \(\mathbf{u}\) is exactly the coordinate vector of \(K\) because \(K=(a,b(1-2s))\).
Therefore

\[
\|\mathbf{u}\| = OK = \sqrt{1-\frac{r^2}{2}}\qquad\text{(by (3))},\qquad \|\mathbf{v}\|=1.
\]

By the Cauchy‑Schwarz inequality,

\[
|\mathbf{u}\cdot\mathbf{v}| \le \|\mathbf{u}\|\,\|\mathbf{v}\| = \sqrt{1-\frac{r^2}{2}}.
\]

Consequently

\[
\left|\frac{4-r^2}{4r}\right| \le \sqrt{1-\frac{r^2}{2}}. \tag{14}
\]

Both sides are non‑negative. Squaring (14) and multiplying by \(16r^2\) yields

\[
(4-r^2)^2 \le 16r^2-8r^4.
\]

Expanding and simplifying:

\[
r^4-8r^2+16 \le 16r^2-8r^4
\quad\Longrightarrow\quad 9r^4-24r^2+16 \le 0
\quad\Longrightarrow\quad (3r^2-4)^2 \le 0.
\]

Hence \(3r^2-4=0\) and, because \(r>0\),

\[
\boxed{OP = r = \frac{2}{\sqrt{3}}}.
\]

---

### 7. Consequences of equality

Equality in (14) forces \(\mathbf{u}\) and \(\mathbf{v}\) to be parallel. Moreover,

\[
\|\mathbf{u}\| = OK = \sqrt{1-\frac{2}{3}} = \frac{1}{\sqrt{3}},\qquad \mathbf{v}\text{ is a unit vector}.
\]

Thus \(\mathbf{u} = \frac{1}{\sqrt{3}}\,\mathbf{v}\), i.e.

\[
K = \frac{1}{\sqrt{3}}(\cos\varphi,\sin\varphi),\qquad
P = r(\cos\varphi,\sin\varphi) = \frac{2}{\sqrt{3}}(\cos\varphi,\sin\varphi) = 2K.
\]

Therefore \(O,K,P\) are collinear and \(K\) is the midpoint of \(OP\).

From (2) with \(r^2=4/3\) we obtain

\[
8b^2 s(1-s) = \frac{4}{3}\quad\Longrightarrow\quad b^2 s(1-s) = \frac{1}{6}. \tag{15}
\]

---

### 8. Coordinates of \(A\) and \(D\)

Since \(P\) lies outside \(\Gamma\), the second intersections of lines \(BP\) and \(CP\) with \(\Gamma\) are \(A\) and \(D\) respectively. Using the secant construction:

\[
A = P + \lambda\,(B-P),\qquad D = P + \mu\,(C-P),
\]

where

\[
\lambda = \frac{\operatorname{Pow}_\Gamma(P)}{PB^2} = \frac{1/3}{PB^2},\qquad
\mu = \frac{1/3}{PC^2}.
\]

We compute \(PB^2\) and \(PC^2\) explicitly.

\[
B-P = (-a,\; b - 2b(1-2s)) = (-a,\; b(4s-1)),
\]

\[
PB^2 = a^2 + b^2(4s-1)^2.
\]

Using \(a^2 = 1-b^2\) and (15) we simplify:

\[
PB^2 = 1 + 8b^2 s(2s-1) = 1 + \frac{4}{3}\cdot\frac{2s-1}{1-s}
= \frac{5s-1}{3(1-s)}. \tag{16}
\]

Hence

\[
\lambda = \frac{1/3}{PB^2} = \frac{1-s}{5s-1}. \tag{17}
\]

Similarly,

\[
C-P = (-a,\; -b-2b(1-2s)) = (-a,\; b(4s-3)),
\]

\[
PC^2 = a^2 + b^2(4s-3)^2 = 1 - 8b^2 (2s-1)(1-s)
= \frac{4-5s}{3s}. \tag{18}
\]

Thus

\[
\mu = \frac{1/3}{PC^2} = \frac{s}{4-5s}. \tag{19}
\]

Now

\[
A = \bigl(a(2-\lambda),\; b[2(1-2s)+\lambda(4s-1)]\bigr), \tag{20}
\]

\[
D = \bigl(a(2-\mu),\; b[2(1-2s)+\mu(4s-3)]\bigr). \tag{21}
\]

---

### 9. Intersection \(Q\) of the diagonals

We find \(Q = AC \cap BD\).
Write

\[
A-C = \bigl(a(1-\lambda),\; y_A+b\bigr),\qquad
D-B = \bigl(a(1-\mu),\; y_D-b\bigr).
\]

It is helpful to simplify these differences. Compute \(1-\lambda\) and \(1-\mu\):

\[
1-\lambda = \frac{6s-2}{5s-1} = \frac{2(3s-1)}{5s-1},\qquad
1-\mu = \frac{4-6s}{4-5s} = \frac{2(2-3s)}{4-5s}. \tag{22}
\]

Using (20) and (21) we evaluate \(y_A+b\) and \(y_D-b\). After straightforward algebra (see details below) one obtains

\[
y_A+b = -\frac{4bM}{5s-1},\qquad
y_D-b = \frac{4bM}{4-5s}, \tag{23}
\]

where

\[
M = 6s^2-6s+1.
\]

Thus

\[
A-C = \left(\frac{2a(3s-1)}{5s-1},\; -\frac{4bM}{5s-1}\right),\qquad
D-B = \left(\frac{2a(2-3s)}{4-5s},\; \frac{4bM}{4-5s}\right). \tag{24}
\]

*Derivation of (23):*

\[
y_A+b = b\bigl[2(1-2s)+\lambda(4s-1)+1\bigr] = b\bigl[3-4s+\lambda(4s-1)\bigr].
\]

Writing \(\lambda = (1-s)/(5s-1)\) and putting over a common denominator gives

\[
y_A+b = b\,\frac{(3-4s)(5s-1)+(1-s)(4s-1)}{5s-1}.
\]

The numerator simplifies to \(-4(6s^2-6s+1) = -4M\). Hence the first formula in (23).
For \(y_D-b\):

\[
y_D-b = b\bigl[2(1-2s)+\mu(4s-3)-1\bigr] = b\bigl[1-4s+\mu(4s-3)\bigr].
\]

Using \(\mu = s/(4-5s)\) we get

\[
y_D-b = b\,\frac{(1-4s)(4-5s)+s(4s-3)}{4-5s} = b\,\frac{4(6s^2-6s+1)}{4-5s} = \frac{4bM}{4-5s}.
\]

Now solve for \(Q\). Parametrise:

\[
Q = C + u(A-C),\qquad Q = B + v(D-B),\quad u,v\in\mathbb{R}.
\]

Equating coordinates yields

\[
a + u\cdot\frac{2a(3s-1)}{5s-1} = a + v\cdot\frac{2a(2-3s)}{4-5s}\;\Longrightarrow\;
u\,\frac{3s-1}{5s-1} = v\,\frac{2-3s}{4-5s}, \tag{25}
\]

\[
-b + u\cdot\left(-\frac{4bM}{5s-1}\right) = b + v\cdot\frac{4bM}{4-5s}.
\]

Divide the second equation by \(b\) and rearrange:

\[
-1 - \frac{4M u}{5s-1} = 1 + \frac{4M v}{4-5s}
\;\Longrightarrow\;
\frac{4M u}{5s-1} + \frac{4M v}{4-5s} = -2.
\]

Divide by \(2\):

\[
\frac{2M u}{5s-1} + \frac{2M v}{4-5s} = -1. \tag{26}
\]

From (25) express \(v\) in terms of \(u\):

\[
v = u\,\frac{3s-1}{5s-1}\cdot\frac{4-5s}{2-3s}. \tag{27}
\]

Substitute into (26). The term \(\dfrac{2M v}{4-5s}\) becomes

\[
\frac{2M}{4-5s}\cdot u\,\frac{3s-1}{5s-1}\cdot\frac{4-5s}{2-3s}
= \frac{2M u\,(3s-1)}{(5s-1)(2-3s)}.
\]

Thus (26) reads

\[
\frac{2M u}{5s-1}\left[1 + \frac{3s-1}{2-3s}\right] = -1.
\]

The bracket simplifies:

\[
1 + \frac{3s-1}{2-3s} = \frac{(2-3s)+(3s-1)}{2-3s} = \frac{1}{2-3s}.
\]

Therefore

\[
\frac{2M u}{(5s-1)(2-3s)} = -1
\quad\Longrightarrow\quad
u = -\frac{(5s-1)(2-3s)}{2M}. \tag{28}
\]

Now the \(y\)-coordinate of \(Q\) from the \(AC\) parametrisation is

\[
y_Q = -b + u\cdot\left(-\frac{4bM}{5s-1}\right)
= -b - \frac{4bM}{5s-1}\,u.
\]

Insert (28):

\[
y_Q = -b - \frac{4bM}{5s-1}\left(-\frac{(5s-1)(2-3s)}{2M}\right)
= -b + 2b(2-3s) = 3b(1-2s). \tag{29}
\]

Thus

\[
\boxed{y_Q = 3b(1-2s)}.
\]

---

### 10. Determination of point \(T\)

Line \(BC\) is vertical, so the perpendicular through \(Q\) is horizontal: \(y = y_Q\).
Line \(OP\) is the ray from \(O\) through \(P\). Since \(P = 2K = (2a,\,2b(1-2s))\), its parametric form is

\[
(x,y) = (2a\,\theta,\;2b(1-2s)\,\theta),\qquad \theta\ge 0.
\]

Set the \(y\)-coordinate equal to \(y_Q\):

\[
2b(1-2s)\,\theta = 3b(1-2s).
\]

Because \(b>0\) and, from the strict inequalities of the problem, \(1-2s\neq 0\) (as will be shown), we may divide to obtain \(\theta = 3/2\). Hence

\[
T = \bigl(2a\cdot\tfrac32,\;2b(1-2s)\cdot\tfrac32\bigr) = \bigl(3a,\;3b(1-2s)\bigr). \tag{30}
\]

---

### 11. Computation of \(TB+TC\)

We have

\[
B = (a,b),\quad C = (a,-b),\quad T = (3a,\,3b(1-2s)).
\]

Define

\[
u = 3(1-2s). \]

Then \(T = (3a,\, b\,u)\). Distances:

\[
TB^2 = (3a-a)^2 + (bu - b)^2 = 4a^2 + b^2(u-1)^2,
\]

\[
TC^2 = 4a^2 + b^2(u+1)^2.
\]

Express \(a^2\) and \(b^2\) in terms of \(u\). From (15): \(b^2 s(1-s) = 1/6\).
Since \(u = 3(1-2s)\), we solve for \(s\):

\[
s = \frac{3-u}{6},\qquad 1-s = \frac{3+u}{6}.
\]

Then

\[
s(1-s) = \frac{(3-u)(3+u)}{36} = \frac{9-u^2}{36}.
\]

Thus

\[
b^2 = \frac{1}{6\,s(1-s)} = \frac{1}{6\cdot\frac{9-u^2}{36}} = \frac{6}{9-u^2}. \tag{31}
\]

\[
a^2 = 1 - b^2 = 1 - \frac{6}{9-u^2} = \frac{3-u^2}{9-u^2}. \tag{32}
\]

Now

\[
TB^2 = 4\cdot\frac{3-u^2}{9-u^2} + \frac{6}{9-u^2}\,(u-1)^2
= \frac{4(3-u^2)+6(u-1)^2}{9-u^2}.
\]

Simplify the numerator:

\[
4(3-u^2)+6(u-1)^2 = 12-4u^2+6(u^2-2u+1)=12-4u^2+6u^2-12u+6
= 18+2u^2-12u = 2(u^2-6u+9) = 2(u-3)^2.
\]

Hence

\[
TB = \frac{|u-3|\sqrt{2}}{\sqrt{9-u^2}}.
\]

Similarly,

\[
TC^2 = 4\cdot\frac{3-u^2}{9-u^2} + \frac{6}{9-u^2}\,(u+1)^2
= \frac{4(3-u^2)+6(u+1)^2}{9-u^2}.
\]

\[
4(3-u^2)+6(u+1)^2 = 12-4u^2+6(u^2+2u+1)=12-4u^2+6u^2+12u+6
= 18+2u^2+12u = 2(u^2+6u+9)=2(u+3)^2.
\]

Thus

\[
TC = \frac{|u+3|\sqrt{2}}{\sqrt{9-u^2}}.
\]

For the admissible range of \(s\) (to be determined) we have \(u\in(-1,0)\). In that interval \(u-3<0\), \(u+3>0\), so

\[
TB = \frac{(3-u)\sqrt{2}}{\sqrt{9-u^2}},\qquad
TC = \frac{(3+u)\sqrt{2}}{\sqrt{9-u^2}}.
\]

Therefore

\[
TB+TC = \frac{\sqrt{2}}{\sqrt{9-u^2}}\bigl((3-u)+(3+u)\bigr)
= \frac{6\sqrt{2}}{\sqrt{9-u^2}}. \tag{33}
\]

---

### 12. Admissible range of \(s\)

The problem imposes

\[
\angle ABC < \angle BCD < 90^\circ
\]

and the quadrilateral is convex with vertices labeled consecutively.

We first obtain expressions for \(\tan\angle ABC\) and \(\tan\angle BCD\) using coordinates.

**Angle at \(B\):**
Vectors \(BA = A-B\) and \(BC = C-B = (0,-2b)\).

\[
BA = (a(1-\lambda),\; y_A-b).
\]

We previously found

\[
a(1-\lambda) = a\cdot\frac{2(3s-1)}{5s-1},\qquad
b - y_A = b(4s-1)(1-\lambda).
\]

Since \(BC\) is vertical downward, the angle between \(BA\) and the downward direction satisfies

\[
\tan\angle ABC = \frac{|a(1-\lambda)|}{b-y_A} = \frac{a}{b(4s-1)}. \tag{34}
\]

(The derivation using the cross product and dot product gives the same result, and the angle is acute when \(b-y_A>0\), i.e. when \(4s-1>0\).)

**Angle at \(C\):**
Vectors \(CB = B-C = (0,2b)\) (upward) and \(CD = D-C = (a(1-\mu),\; y_D+b)\).

We have

\[
a(1-\mu) = a\cdot\frac{2(2-3s)}{4-5s},\qquad
y_D+b = b(3-4s)(1-\mu).
\]

Because \(CB\) is vertical upward,

\[
\tan\angle BCD = \frac{|a(1-\mu)|}{y_D+b} = \frac{a}{b(3-4s)}. \tag{35}
\]

Acuteness requires \(y_D+b>0\), i.e. \(3-4s>0\).

Now the conditions:

- \(\angle ABC,\angle BCD\) acute \(\Longrightarrow 4s-1>0\) and \(3-4s>0\) \(\Longrightarrow \frac14 < s < \frac34\).
- \(\angle ABC < \angle BCD\) (both acute, so tangents are increasing) \(\Longrightarrow\)

\[
\frac{a}{b(4s-1)} < \frac{a}{b(3-4s)}
\;\Longleftrightarrow\; 3-4s < 4s-1
\;\Longleftrightarrow\; s > \frac12.
\]

Thus \(s\in (\frac12,\frac34)\).

**Convexity constraints:**
For the quadrilateral to be convex with vertices in order \(A,B,C,D\), the points must lie on the lines \(BP\) and \(CP\) in the order \(P\!-\!A\!-\!B\) and \(P\!-\!D\!-\!C\). This is equivalent to \(0<\lambda<1\) and \(0<\mu<1\).

From (17): \(\lambda = \dfrac{1-s}{5s-1}\).
\(\lambda>0\) requires \(5s-1>0\) (already true for \(s>\frac12\)), and \(\lambda<1\) gives

\[
\frac{1-s}{5s-1}<1 \;\Longleftrightarrow\; 1-s < 5s-1 \;\Longleftrightarrow\; s>\frac13.
\]

So \(\lambda\in(0,1)\) holds for \(s>\frac13\).

From (19): \(\mu = \dfrac{s}{4-5s}\).
\(\mu>0\) requires \(4-5s>0\) i.e. \(s<\frac45\); \(\mu<1\) gives

\[
\frac{s}{4-5s}<1 \;\Longleftrightarrow\; s < 4-5s \;\Longleftrightarrow\; s<\frac23.
\]

Hence \(\mu\in(0,1)\) gives \(s<\frac23\).

Convexity therefore requires \(s\in(\frac13,\frac23)\).

Intersecting this with \(s\in(\frac12,\frac34)\) yields

\[
\boxed{s\in\left(\frac12,\,\frac23\right)}.
\]

At the endpoints the strict angle inequalities fail (\(s=\frac12\) gives equality) or the quadrilateral degenerates (\(s=\frac23\) gives \(D\equiv C\)). Hence \(s\) varies strictly inside this open interval.

For these values, \(1-2s<0\) and

\[
u = 3(1-2s) \in (-1,\,0).
\]

---

### 13. Possible values of \(TB+TC\)

From (33), \(TB+TC = \dfrac{6\sqrt{2}}{\sqrt{9-u^2}}\) with \(u\in(-1,0)\). As \(s\) increases from \(\frac12\) to \(\frac23\), \(u\) decreases continuously from \(0\) to \(-1\) and the function is strictly increasing (since \(9-u^2\) decreases). Therefore \(TB+TC\) takes all values between its limits at the endpoints:

\[
\lim_{u\to 0^-} TB+TC = \frac{6\sqrt{2}}{3} = 2\sqrt{2},\qquad
\lim_{u\to -1^+} TB+TC = \frac{6\sqrt{2}}{\sqrt{8}} = 3.
\]

Because the endpoints are not attained,

\[
\boxed{2\sqrt{2} < TB+TC < 3}.
\]

---

### 14. Summary

\[
\boxed{OP = \frac{2}{\sqrt{3}}},\qquad
\boxed{2\sqrt{2} < TB+TC < 3}.
\]


Question:
Let $n$ be an positive integer. There are $n$ red cards and $n$ blue cards. Initially, there is a real number $0$ on each red card, and a real number $1$ on each blue card. One operation is: choose a red card and a blue card, such that the real number $x$ on the red card is smaller than the real number $y$ on the blue card, erase these two numbers and write down $\frac{x + y}{2}$ instead on both cards.
Find the smallest positive integer $n$, such that one can appropriately operate finite times to make the sum of real numbers on red cards be larger than $100$.

We have \(n\) red cards (each initially \(0\)) and \(n\) blue cards (each initially \(1\)).
An operation consists of choosing a red card with value \(x\) and a blue card with value \(y\) such that \(x<y\), erasing both numbers and writing \(\frac{x+y}{2}\) on **both** cards.

Let \(R\) be the sum of numbers on the red cards and \(B\) the sum on the blue cards.
The total sum \(R+B\) is invariant because
\[
(x+y)\;\longrightarrow\;2\cdot\frac{x+y}{2}=x+y.
\]
Initially \(R+B=n\). Each operation increases \(R\) by \(\frac{y-x}{2}>0\) and decreases \(B\) by the same amount.
To maximise \(R\) we continue until no further operation is possible, i.e. until
\[
\min\{\text{red values}\}\ge \max\{\text{blue values}\}.
\]

---

### 1. Optimal order for a fixed blue card

**Lemma 1.**
For a fixed blue card with current value \(b\), the total increase of the red sum is maximised if we always choose, among the red cards whose value is less than \(b\), the one with the **largest** value.

*Proof.*
Let two red cards have values \(r<s<b\). Compare two orders:

* \(A\): use \(s\) first, then \(r\);
* \(B\): use \(r\) first, then (if possible) \(s\).

Denote the initial blue value by \(b\).

- Order \(A\):
  First operation: \(\Delta_1=\frac{b-s}{2}\); new blue \(b'=\frac{s+b}{2}\).
  Second operation (always possible because \(b'>s>r\)): \(\Delta_2=\frac{b'-r}{2}=\frac{s+b-2r}{4}\).
  Total \(\Delta_A=\frac{b-s}{2}+\frac{s+b-2r}{4}=\frac{3b-s-2r}{4}\).

- Order \(B\):
  First: \(\Delta_1'=\frac{b-r}{2}\); new blue \(b''=\frac{r+b}{2}\).
  If \(b''>s\) then \(\Delta_2'=\frac{b''-s}{2}=\frac{r+b-2s}{4}\), total \(\Delta_B=\frac{b-r}{2}+\frac{r+b-2s}{4}=\frac{3b-r-2s}{4}\).
  If \(b''\le s\) the second operation is impossible and \(\Delta_B=\frac{b-r}{2}\).

In the first case \(\Delta_A-\Delta_B=\frac{s-r}{4}>0\); in the second case \(\Delta_A-\Delta_B=\frac{b-s}{4}>0\).
Thus \(\Delta_A>\Delta_B\). By repeatedly improving any non‑optimal order we obtain that the decreasing order of reds is optimal. ∎

**Corollary.**
If initially all red values are less than \(b\), the optimal procedure uses every red exactly once, in decreasing order of their current values, and ends when the blue value equals the smallest red.

---

### 2. Global ordering of operations

**Lemma 2.**
In an optimal sequence, for each red card the values of the blue cards at the moments it is used form a non‑decreasing sequence.

*Proof.*
Suppose, for contradiction, that an optimal sequence \(\mathcal S\) contains a red card \(R\) that is used with a blue card \(A\) of value \(a\) and later with a blue card \(B\) of value \(b<a\). Choose such a triple with the smallest possible number of operations between the two uses (i.e., minimise \(t_2-t_1\)). Denote these operations by \(O_1=(R,A)\) at step \(t_1\) and \(O_2=(R,B)\) at step \(t_2\).

First we show that there is no operation involving \(R\) strictly between \(t_1\) and \(t_2\). If there were an operation \(O'=(R,C)\) with \(t_1<t'<t_2\), let its blue value be \(c\). Because \(t_2-t'<t_2-t_1\), the minimality of our choice forces that \(c\ge a\) (otherwise \(O_1\) and \(O'\) would be a closer decrease). But then \(c\ge a > b\), so \(O'\) and \(O_2\) would be a decrease with fewer operations between them, contradicting minimality. Hence no operation with \(R\) lies between \(O_1\) and \(O_2\).

Now consider any operation \(X\) that occurs between \(O_1\) and \(O_2\). Because \(X\) does not involve \(R\), it must involve a blue card and a red card different from \(R\). We distinguish three types:

1. \(X\) involves \(A\) (and some red \(S\neq R\)). Since \(X\) uses \(A\) and \(S\), it is disjoint from the set \(\{R,B\}\) (the cards of \(O_2\)). Therefore we can swap \(X\) with \(O_2\), moving \(X\) after \(O_2\), without affecting the final configuration or the legality of the operations (because \(X\) does not change \(R\) or \(B\), and \(O_2\) does not change \(A\) or \(S\)).

2. \(X\) involves \(B\) (and some red \(T\neq R\)). Then \(X\) is disjoint from \(\{R,A\}\) and can be swapped with \(O_1\), moving \(X\) before \(O_1\).

3. \(X\) involves neither \(A\) nor \(B\). Then \(X\) is disjoint from both \(\{R,A\}\) and \(\{R,B\}\), so it can be swapped either with \(O_1\) or with \(O_2\); we move it before \(O_1\) or after \(O_2\) arbitrarily.

Repeating these swaps for every operation between \(O_1\) and \(O_2\), we obtain a new sequence \(\mathcal S'\) in which \(O_1\) and \(O_2\) are consecutive and all other operations are unchanged. Moreover, these swaps do not alter the total red sum because disjoint operations commute.

Now examine the two consecutive operations \(O_1\) and \(O_2\). Let \(r\) be the value of \(R\) just before \(O_1\), and let \(a\) and \(b\) be the values of \(A\) and \(B\) at that moment (note that \(b<a\) by assumption). Legality of \(O_1\) gives \(r<a\). Legality of \(O_2\) in the original (after \(O_1\)) gives \(\frac{r+a}{2}<b\), i.e. \(r+a<2b\). Since \(a>b\), we have \(r<2b-a<b\), so \(r<b\).

We compare the total increase in red sum contributed by these two operations in the original order and in the swapped order.

- Original order (\(O_1\) then \(O_2\)):
  \[
  \Delta_{\text{orig}} = \frac{a-r}{2} + \frac{b-\frac{r+a}{2}}{2}
  = \frac{a+2b-3r}{4}.
  \]
- Swapped order (\(O_2\) then \(O_1\)):
  \[
  \Delta_{\text{swap}} = \frac{b-r}{2} + \frac{a-\frac{r+b}{2}}{2}
  = \frac{2a+b-3r}{4}.
  \]

Because \(a>b\), we have \(\Delta_{\text{swap}} - \Delta_{\text{orig}} = \frac{a-b}{4} > 0\). Furthermore, after swapping the two operations are still legal: after \(O_2\) the new value of \(R\) is \(\frac{r+b}{2}\), which is less than \(a\) because \(r<b<a\) implies \(\frac{r+b}{2} < a\). Hence the swapped sequence yields a strictly larger total red sum while still being valid. This contradicts the optimality of \(\mathcal S\). Therefore no such decrease can exist. ∎

**Proposition 1.**
There exists an optimal sequence in which the blue cards are processed one after another: we take an ordering of the blues, and for each blue in turn we perform operations with it (using the reds in decreasing order) until it is exhausted, before moving to the next blue.

*Proof.*
Consider any optimal sequence. Let \(B_1\) be the blue used in the first operation. Suppose that before \(B_1\) has been used with all reds, an operation involving a different blue \(B_2\) occurs; take the earliest such operation.

Let \(R\) be a red that will be used with \(B_1\) later (such a red exists because \(B_1\) is not yet exhausted).
- If the \(B_2\) operation involved \(R\), then \(R\) would meet \(B_2\) (value \(1\)) before later meeting \(B_1\) (value \(<1\)), contradicting Lemma 2. Hence it involves another red \(S\).
- If \(S\) were later used with \(B_1\), then \(S\) would meet \(B_2\) (value \(1\)) and later \(B_1\) (value \(<1\)), again contradicting Lemma 2. Thus \(S\) is already finished with \(B_1\).

The operation \((S,B_2)\) and the future operation \((R,B_1)\) involve four distinct cards; therefore they can be swapped without affecting the final outcome. By repeatedly swapping we can move the \((S,B_2)\) operation after the whole block of \(B_1\) operations. Applying this argument to every intrusion of another blue, we obtain an optimal sequence where \(B_1\) is completely processed before any other blue is touched.

After removing \(B_1\) (its final value is the smallest and will never be used again), the same reasoning applied inductively shows that the remaining blues can be processed consecutively as well.

Finally, inside each blue’s block we may reorder the operations to follow the descending order of the reds (Lemma 1) without changing the total red sum. ∎

---

### 3. The greedy algorithm and recurrence

From now on we work with the optimal strategy described in Proposition 1. Sort the reds in non‑increasing order: \(r_1\ge r_2\ge\dots\ge r_n\). Initially \(r_i^{(0)}=0\).

Processing the next blue (starting at \(1\)) updates the reds as follows:

\[
\begin{aligned}
r_1^{(t)} &= \frac{1 + r_1^{(t-1)}}{2}, \\[4pt]
r_i^{(t)} &= \frac{r_{i-1}^{(t)} + r_i^{(t-1)}}{2}, \qquad i=2,\dots,n.
\end{aligned}
\tag{1}
\]

It is easy to verify by induction that the order is preserved.

---

### 4. Extension to an infinite system

To solve (1) we consider an auxiliary infinite set of red cards indexed by \(i=1,2,3,\dots\), all initially \(0\). Process \(n\) blues using the same rule, i.e. for each blue we define the transformation (1) for all \(i\ge1\). This yields an infinite sequence \(\bigl(r_i^{(t)}\bigr)_{i\ge1}\) for each \(t\). For every \(t\le n\) and \(i\le n\) the value coincides with that of the original finite system, because the extra reds do not influence the first \(n\) positions. Thus we may work with the infinite system.

---

### 5. Generating function

Define

\[
F_t(x) = \sum_{i=1}^{\infty} r_i^{(t)} x^{i-1} \qquad (t=0,1,\dots,n),
\]

a formal power series. From (1) we derive

\[
(2-x)F_t(x) = 1 + F_{t-1}(x). \tag{2}
\]

Indeed,

\[
\begin{aligned}
F_t(x) &= \frac{1+r_1^{(t-1)}}{2} + \frac12\sum_{i\ge2} r_{i-1}^{(t)} x^{i-1} + \frac12\sum_{i\ge2} r_i^{(t-1)} x^{i-1} \\
&= \frac12 + \frac{x}{2}F_t(x) + \frac12 F_{t-1}(x),
\end{aligned}
\]

which rearranges to \((2-x)F_t = 1 + F_{t-1}\).

Starting with \(F_0(x)=0\), iteration gives

\[
F_n(x) = \frac{(2-x)^n - 1}{(1-x)(2-x)^n}. \tag{3}
\]

---

### 6. Total red sum and blue sum

The total red sum after \(n\) blues is \(R_{\max}(n) = \sum_{i=1}^n r_i^{(n)}\). Observe that

\[
\frac{F_n(x)}{1-x} = \sum_{m=0}^{\infty} \biggl( \sum_{i=1}^{m+1} r_i^{(n)} \biggr) x^m,
\]

so the coefficient of \(x^{n-1}\) equals \(R_{\max}(n)\). Using (3),

\[
\frac{F_n(x)}{1-x} = \frac{1}{(1-x)^2} - \frac{1}{(1-x)^2(2-x)^n}.
\]

The coefficient of \(x^{n-1}\) in \(\frac{1}{(1-x)^2}\) is \(n\). Hence

\[
R_{\max}(n) = n - B(n), \qquad B(n) = [x^{n-1}] \frac{1}{(1-x)^2(2-x)^n}. \tag{4}
\]

\(B(n)\) is the sum of the final blue values.

---

### 7. Series expansion of \(B(n)\)

\[
\frac{1}{(1-x)^2} = \sum_{j=0}^{\infty} (j+1)x^j,\qquad
\frac{1}{(2-x)^n} = \sum_{k=0}^{\infty} \binom{n+k-1}{k} \frac{x^k}{2^{n+k}}.
\]

Multiplying and taking the coefficient of \(x^{n-1}\) gives

\[
B(n) = \sum_{k=0}^{n-1} (n-k) \frac{\binom{n+k-1}{k}}{2^{n+k}}. \tag{5}
\]

Define

\[
g_k^{(n)} = \frac{\binom{n+k-1}{k}}{2^{n+k}}, \quad k\ge 0.
\]

---

### 8. Recurrence for \(g_k^{(n)}\)

From \((2-x)\frac{1}{(2-x)^n} = \frac{1}{(2-x)^{n-1}}\) we obtain

\[
(2-x)\sum_{k\ge0} g_k^{(n)} x^k = \sum_{k\ge0} g_k^{(n-1)} x^k.
\]

Comparing coefficients:

\[
2g_0^{(n)} = g_0^{(n-1)},\qquad
2g_k^{(n)} - g_{k-1}^{(n)} = g_k^{(n-1)}\;\;(k\ge1). \tag{6}
\]

---

### 9. The sum \(A_n = \sum_{k=0}^{n-1} g_k^{(n)}\)

We prove \(A_n = \frac12\) for all \(n\ge1\).

Sum (6) for \(k=0,\dots,n-1\) (with \(g_{-1}^{(n)}=0\)):

\[
2\sum_{k=0}^{n-1} g_k^{(n)} - \sum_{k=0}^{n-1} g_{k-1}^{(n)} = \sum_{k=0}^{n-1} g_k^{(n-1)}.
\]

The second sum equals \(\sum_{j=-1}^{n-2} g_j^{(n)} = A_n - g_{n-1}^{(n)}\). The right-hand side is \(A_{n-1} + g_{n-1}^{(n-1)}\) because the sum runs up to \(k=n-1\). Hence

\[
2A_n - (A_n - g_{n-1}^{(n)}) = A_{n-1} + g_{n-1}^{(n-1)} \;\Longrightarrow\; A_n + g_{n-1}^{(n)} = A_{n-1} + g_{n-1}^{(n-1)}.
\]

A direct calculation shows \(g_{n-1}^{(n)} = g_{n-1}^{(n-1)}\) (using \(\binom{2n-2}{n-1}=2\binom{2n-3}{n-1}\)). Thus \(A_n = A_{n-1}\). With \(A_1 = g_0^{(1)} = \frac12\), we obtain \(A_n = \frac12\) for all \(n\).

---

### 10. Recurrence for \(B(n)\)

Using (5) and (6):

\[
B(n) = \frac12 \sum_{k=0}^{n-1} (n-k) g_k^{(n-1)} + \frac12 \sum_{k=0}^{n-1} (n-k) g_{k-1}^{(n)}.
\]

The first sum splits as

\[
\sum_{k=0}^{n-1} (n-k) g_k^{(n-1)} = \sum_{k=0}^{n-2} (n-k) g_k^{(n-1)} + g_{n-1}^{(n-1)}.
\]

For \(k=0,\dots,n-2\) write \(n-k = (n-1-k)+1\); thus

\[
\sum_{k=0}^{n-2} (n-k) g_k^{(n-1)} = B(n-1) + A_{n-1}.
\]

The second sum, after the substitution \(j=k-1\), becomes

\[
\sum_{j=0}^{n-2} (n-1-j) g_j^{(n)} = \biggl(\sum_{j=0}^{n-1} (n-j) g_j^{(n)}\biggr) - \sum_{j=0}^{n-1} g_j^{(n)} = B(n) - A_n.
\]

Hence

\[
B(n) = \frac12 \bigl( B(n-1) + A_{n-1} + g_{n-1}^{(n-1)} \bigr) + \frac12 \bigl( B(n) - A_n \bigr).
\]

Multiplying by 2 and using \(A_{n-1}=A_n=\frac12\) gives

\[
B(n) = B(n-1) + g_{n-1}^{(n-1)}. \tag{7}
\]

Since \(B(1)=g_0^{(1)}=\frac12\) and \(g_{n-1}^{(n-1)} = \frac12 \frac{\binom{2n-2}{n-1}}{4^{n-1}}\) (as shown in the previous section), iteration yields

\[
B(n) = \frac12 \sum_{k=0}^{n-1} \frac{\binom{2k}{k}}{4^k}. \tag{8}
\]

---

### 11. A combinatorial identity

\[
\sum_{k=0}^{n-1} \frac{\binom{2k}{k}}{4^k} = \frac{2n}{4^n}\binom{2n}{n}. \tag{9}
\]

*Proof by induction.*
For \(n=1\) both sides equal \(1\). Assume true for \(n\). Then

\[
\begin{aligned}
\sum_{k=0}^{n} \frac{\binom{2k}{k}}{4^k}
&= \frac{2n}{4^n}\binom{2n}{n} + \frac{\binom{2n}{n}}{4^n}
= \frac{\binom{2n}{n}}{4^n}(2n+1).
\end{aligned}
\]

Using \(\displaystyle \binom{2n+2}{n+1} = \frac{2(2n+1)}{n+1}\binom{2n}{n}\), the right‑hand side for \(n+1\) is

\[
\frac{2(n+1)}{4^{n+1}}\binom{2n+2}{n+1}
= \frac{2(n+1)}{4^{n+1}}\cdot\frac{2(2n+1)}{n+1}\binom{2n}{n}
= \frac{2n+1}{4^n}\binom{2n}{n},
\]

which matches the expression above. ∎

Substituting (9) into (8) we obtain

\[
B(n) = \frac12 \cdot \frac{2n}{4^n}\binom{2n}{n} = n\,\frac{\binom{2n}{n}}{4^n}.
\]

Therefore the maximal possible red sum is

\[
R_{\max}(n) = n - n\,\frac{\binom{2n}{n}}{4^n}. \tag{10}
\]

---

### 12. Monotonicity

Let \(a_n = \frac{\binom{2n}{n}}{4^n}\). Then \(a_{n+1}=a_n\frac{2n+1}{2n+2}\). Compute

\[
\begin{aligned}
R_{\max}(n+1)-R_{\max}(n)
&= 1 - (n+1)a_{n+1} + n a_n \\
&= 1 - a_n\frac{2n+1}{2} + n a_n \\
&= 1 - \frac{a_n}{2}\; >\;0 \qquad (\text{since } a_n<1).
\end{aligned}
\]

Thus \(R_{\max}(n)\) is strictly increasing in \(n\).

---

### 13. Bounds for \(a_n\) using Wallis integrals

For \(m\ge 0\) define

\[
I_m = \int_0^{\pi/2} \sin^m \theta \, d\theta.
\]

Integration by parts yields the reduction formula \(I_m = \frac{m-1}{m} I_{m-2}\) for \(m\ge 2\). With \(I_0=\frac{\pi}{2}\), \(I_1=1\), an easy induction gives

\[
I_{2n} = \frac{(2n)!}{(2^n n!)^2} \cdot \frac{\pi}{2}
= a_n \cdot \frac{\pi}{2},
\qquad
I_{2n+1} = \frac{2^{2n} (n!)^2}{(2n+1)!}
= \frac{1}{(2n+1) a_n}.
\]

The sequence \(I_m\) is strictly decreasing. Hence \(I_{2n} > I_{2n+1} > I_{2n+2}\).

- \(I_{2n} > I_{2n+1}\) gives \(\frac{\pi}{2}a_n > \frac{1}{(2n+1)a_n}\)  \(\Longrightarrow\)  \(a_n^2 > \frac{2}{\pi(2n+1)} = \frac{1}{\pi(n+\frac12)}\).
- \(I_{2n+1} > I_{2n+2}\) gives \(\frac{1}{(2n+1)a_n} > \frac{\pi}{2}a_{n+1}\). Using \(a_{n+1}=a_n\frac{2n+1}{2n+2}\) this becomes

\[
\frac{1}{(2n+1)a_n} > \frac{\pi}{2}a_n\frac{2n+1}{2n+2}
\;\Longrightarrow\;
a_n^2 < \frac{2}{\pi}\cdot\frac{2n+2}{(2n+1)^2} = \frac{4(n+1)}{\pi(2n+1)^2}.
\]

Now \(4(n+1) < \frac{(2n+1)^2}{n}\) because \(4n(n+1) = 4n^2+4n < 4n^2+4n+1 = (2n+1)^2\). Hence \(a_n^2 < \frac{1}{\pi n}\).

Thus we have the tight bounds

\[
\frac{1}{\sqrt{\pi\!\left(n+\frac12\right)}} \;<\; a_n \;<\; \frac{1}{\sqrt{\pi n}}. \tag{11}
\]

---

### 14. Finding the smallest \(n\) with \(R_{\max}(n)>100\)

Because \(R_{\max}(n)\) is strictly increasing, we test consecutive values.

**For \(n=105\):**
Using the lower bound of (11),

\[
a_{105} > \frac{1}{\sqrt{\pi\cdot105.5}}.
\]

Now \(\pi\cdot105.5 < 3.1416\times105.5 = 331.4388 < 441 = 21^2\), so \(\sqrt{\pi\cdot105.5} < 21\). Hence

\[
\frac{1}{\sqrt{\pi\cdot105.5}} > \frac{1}{21}.
\]

Consequently \(a_{105} > \frac{1}{21}\). Then

\[
R_{\max}(105) = 105(1-a_{105}) < 105\left(1-\frac{1}{21}\right) = 105\cdot\frac{20}{21} = 100.
\]

Thus \(R_{\max}(105) < 100\).

**For \(n=106\):**
Using the upper bound of (11),

\[
a_{106} < \frac{1}{\sqrt{\pi\cdot106}}.
\]

We have \(\pi\cdot106 > 3.14\times106 = 332.84\). Since \(\left(\frac{53}{3}\right)^2 = \frac{2809}{9} \approx 312.11\), we get \(\sqrt{\pi\cdot106} > \frac{53}{3}\). Therefore

\[
\frac{1}{\sqrt{\pi\cdot106}} < \frac{3}{53}.
\]

Hence \(a_{106} < \frac{3}{53}\), and

\[
R_{\max}(106) = 106(1-a_{106}) > 106\left(1-\frac{3}{53}\right) = 106\cdot\frac{50}{53} = 100.
\]

Thus \(R_{\max}(106) > 100\).

Therefore \(R_{\max}(105) < 100 < R_{\max}(106)\), and by monotonicity \(n=106\) is the smallest positive integer for which one can achieve a red sum larger than \(100\).

\[
\boxed{106}
\]

---


Question:
There are 30 colors of cards, with 70 cards of each color. Initially, 70 cards are chosen arbitrarily and stacked from top to bottom to form a pile.

One operation is defined as follows:
From the bottom 20 cards, choose a card $X$ whose color does *not* appear among the top 50 cards. Then, from the top 50 cards, choose a card $Y$ whose color appears at least twice among the top 50 cards. Remove $X$ and reinsert it immediately above $Y$. Repeat this operation until it is no longer possible to select such an $X$.

(1) Prove that the operation can only be performed finitely many times.
(2) Over all possible initial configurations and choices of operations, determine the maximum possible number of operations.

We consider the pile of \(70\) cards. The top \(50\) positions are called the *top*, the bottom \(20\) the *bottom*. For a colour \(i\) let

* \(a_i\) = number of cards of colour \(i\) in the top,
* \(b_i\) = number of cards of colour \(i\) in the bottom.

Thus \(a_i+b_i\) is the total number of cards of colour \(i\) in the whole pile (fixed during the process).

Define the following sets of colours:

* \(A = \{\,i \mid a_i = 0,\; b_i>0 \,\}\) – colours missing from the top,
* \(B = \{\,i \mid a_i = 1 \,\}\) – colours occurring exactly once in the top,
* \(C = \{\,i \mid a_i \ge 2 \,\}\) – colours occurring at least twice in the top.

Let \(M = |A|\), \(U = |B|\), \(V = |C|\).

---

### 1.  Basic observations

* The top contains \(50\) cards, therefore
  \[
  U + \sum_{i\in C} a_i = 50. \tag{1}
  \]
* The bottom contains \(20\) cards, so
  \[
  \sum_{i\in A} b_i + \sum_{i\notin A} b_i = 20. \tag{2}
  \]
  In particular each colour in \(A\) contributes at least one to the sum, hence
  \[
  M \le 20. \tag{3}
  \]
* By the pigeonhole principle, with \(50\) cards and only \(30\) colours, we must have \(V\ge 1\); i.e. there is always at least one colour with \(a_i\ge 2\). Consequently a legal \(Y\) exists whenever an \(X\) exists.
* The total number of colours actually present is \(M+U+V\). Since there are only \(30\) colours,
  \[
  M+U+V \le 30.
  \]
  Because \(V\ge 1\), we obtain the key inequality
  \[
  M+U \le 29. \tag{4}
  \]

---

### 2.  Effect of one operation

Let the chosen card \(X\) have colour \(c\) and the card \(Y\) have colour \(d\). The card that ends up at position \(50\) before the insertion (the *demoted* card) will be denoted by \(D\); its colour is called \(e\).

From the description of the operation one checks that the only changes in the numbers \(a_i,b_i\) are:

* \(a_c\) increases by \(1\) (from \(0\) to \(1\)), \(b_c\) decreases by \(1\).
* \(a_e\) decreases by \(1\), \(b_e\) increases by \(1\).

All other colours are unchanged.

We distinguish two types of moves according to the multiplicity of the demoted colour \(e\) before the move:

* **Type 1** (the “good” case): \(a_e \ge 2\) (i.e. \(e\in C\)). Then after the move
  * \(M\) decreases by \(1\) (colour \(c\) leaves \(A\), colour \(e\) stays out of \(A\) because \(a_e\) remains \(\ge 1\)).
  * \(U\) may increase by \(1\) or \(2\) (the promoted colour \(c\) joins \(B\); if \(a_e=2\) then \(e\) moves from \(C\) to \(B\) so \(U\) increases by \(2\), otherwise \(U\) increases by \(1\)). In any case \(U\) does not decrease.

* **Type 2**: \(a_e = 1\) (i.e. \(e\in B\)). Then
  * \(M\) stays the same (colour \(c\) leaves \(A\), colour \(e\) enters \(A\)).
  * \(U\) stays the same (colour \(c\) joins \(B\), colour \(e\) leaves \(B\)).

---

### 3.  A useful parameter – the *suffix* of \(B\)

Since \(C\neq\varnothing\), we can look at the rightmost card in the top that belongs to \(C\). Let its position be \(p\). All cards after position \(p\) are necessarily from \(B\) (otherwise a card of \(C\) would be even farther to the right). Define

\[
\Psi \;=\; \text{number of }B\text{-cards after the rightmost }C\text{-card}
 \;=\; 50-p.
\]

Clearly \(0\le \Psi \le U\).

*If \(\Psi>0\) then the last card (position \(50\)) is a \(B\)-card. Consequently the demoted colour \(e\) belongs to \(B\) and the move is of type 2.*

Now examine what happens to \(\Psi\) during a type 2 move.

* The demoted card is the last card, a \(B\)-card, so it is one of the \(\Psi\) cards that lie after the rightmost \(C\).
* The promoted card becomes a \(B\)-card, but it is inserted **above** the chosen \(Y\). Since \(Y\) is a \(C\)-card and lies **not to the right** of the rightmost \(C\), the new \(B\)-card ends up **before** the rightmost \(C\). Hence it does **not** join the block after that \(C\).
* All other \(B\)-cards that were after the rightmost \(C\) keep their relative order and remain after it, except that the last one has been removed.

Therefore \(\Psi\) **decreases by exactly 1** in every type 2 move.

Moreover, as long as \(\Psi>0\) the last card is a \(B\)-card, so the next move **must** be of type 2. Hence type 2 moves continue until \(\Psi\) becomes \(0\). Once \(\Psi=0\), the last card is a \(C\)-card and the next move will be of type 1.

Consequently, between two consecutive type 1 moves (or before the first type 1 move) the number of type 2 moves is exactly the value of \(\Psi\) at the beginning of that block, which is at most \(U\).

---

### 4.  Upper bound on the total number of moves

Let \(M_0\) be the initial value of \(M\). By (3) we have \(M_0\le 20\).

During the whole process type 1 moves can occur only when \(\Psi=0\) and each such move reduces \(M\) by exactly \(1\). Hence the number of type 1 moves is at most \(M_0\) (in fact exactly \(M_0\) if we finally reach \(M=0\)).

Between type 1 moves the value of \(M\) is constant. While \(M=k\) (\(1\le k\le M_0\)), the number \(U\) satisfies \(U\le 29-k\) by (4). The block of type 2 moves that occurs while \(M=k\) consists of at most \(U\) moves, therefore at most \(29-k\) moves.

Summing over all possible values of \(k\) that actually appear (they are a subset of \(\{1,2,\dots,M_0\}\)) we obtain

\[
\text{total moves}
\;\le\; \bigl(\text{number of type 1 moves}\bigr)
      \;+\; \sum_{k=1}^{M_0} (29-k)
\;\le\; M_0 \;+\; \sum_{k=1}^{M_0} (29-k).
\]

Because \(M_0\le 20\), the right‑hand side is maximised when \(M_0=20\), giving

\[
20 \;+\; \sum_{k=1}^{20} (29-k)
\;=\; 20 \;+\; \bigl(29\cdot20 - \tfrac{20\cdot21}{2}\bigr)
\;=\; 20 \;+\; (580-210)
\;=\; 390.
\]

Thus **no sequence of operations can exceed 390**. In particular the operation can be performed only finitely many times, proving part (1).

---

### 5.  Construction attaining 390 moves

We now exhibit an initial configuration and a strategy that achieves exactly \(390\) operations.

* **Colours.** Use all \(30\) colours. Fix one colour, say colour \(1\), to be the unique \(C\)-colour; it will always satisfy \(a_1\ge 2\). The remaining \(29\) colours will alternate between \(A\) and \(B\).
* **Initial numbers.**
  * Let \(a_1 = 41\), \(b_1 = 0\).
  * Choose \(9\) distinct colours to be initially in \(B\). For each of them set \(a_i = 1\), \(b_i = 0\).
  * The other \(20\) colours are initially in \(A\). For each of them set \(a_i = 0\), \(b_i = 1\).
  Check: top total \(41+9 = 50\), bottom total \(20\), all cards sum to \(70\).

* **Initial order in the top.**
  Place all \(41\) cards of colour \(1\) first, then the \(9\) cards of the \(B\)-colours (in any order). Thus the rightmost card is a \(B\)-card, so initially \(\Psi = 9\).

* **Strategy.**
  We will repeatedly execute the following *round* while \(M>0\):

  1. **Phase 2 (type 2 moves).** As long as the rightmost card is a \(B\)-card (i.e. \(\Psi>0\)), perform a move choosing
     * \(X\): any card from the bottom whose colour is in \(A\) (there are always \(M\) such cards),
     * \(Y\): the **rightmost** card of colour \(1\) (i.e. the rightmost \(C\)-card).
     This is a type 2 move; it promotes the chosen \(A\)-colour to \(B\) and demotes the last \(B\)-card. By the analysis, after each such move \(\Psi\) decreases by \(1\) while \(M\) and \(U\) stay constant.

  2. **Phase 1 (type 1 move).** When \(\Psi\) becomes \(0\), the last card is colour \(1\). Now perform one move with
     * \(X\): any card from the bottom whose colour is in \(A\) (still \(M\) of them),
     * \(Y\): again the rightmost card of colour \(1\) (which is the last card).
     This is a type 1 move: it promotes the chosen \(A\)-colour to \(B\) and demotes one colour‑\(1\) card. Consequently
        * \(M\) decreases by \(1\),
        * \(U\) increases by \(1\) (the demoted colour‑\(1\) card stays in \(C\) because \(a_1\) was at least \(2\)),
        * the number of colour‑\(1\) cards in the top, \(a_1\), decreases by \(1\).

     After this move one checks that the top order again consists of all remaining colour‑\(1\) cards (now \(a_1\) of them) followed by all \(U\) \(B\)-cards, with the last card being a \(B\)-card, i.e. \(\Psi = U\).

Thus after each round the parameters change as

\[
(M,\,U,\,a_1) \;\longrightarrow\; (M-1,\, U+1,\, a_1-1),
\]

and the invariant “top = (colour 1 repeated \(a_1\) times) followed by (all \(B\)-cards)” is restored, with \(\Psi = U\).

Start with \((M,U,a_1) = (20,9,41)\). The process goes through the values

\[
\begin{array}{c|ccc}
\text{round} & M & U & a_1 \\ \hline
\text{start}  & 20 & 9 & 41 \\
\text{after 1st round} & 19 & 10 & 40 \\
\text{after 2nd round} & 18 & 11 & 39 \\
\vdots & \vdots & \vdots & \vdots \\
\text{after 20th round} & 0 & 29 & 21
\end{array}
\]

In the round where \(M = k\) (\(k\) runs from \(20\) down to \(1\)) we perform exactly \(U\) type 2 moves, where \(U = 29-k\) (because before the round \(M=k\) and \(U = 29-M = 29-k\)), followed by one type 1 move.

Total number of operations =

\[
\sum_{k=1}^{20} (29-k) \;+\; 20 \;=\; (9+10+\cdots+28) + 20 \;=\; 370 + 20 \;=\; 390.
\]

After the last type 1 move we obtain \(M=0\); no \(X\) exists, so the process stops.

Hence **390 operations are achievable**, and together with the upper bound this is the maximum possible number.

---


Question:
Find all real numbers $\lambda$ such that there exists a positive integer $N$ with the following property:
   for every integer $n \ge N$ and for all non-negative real numbers
   $x_1, x_2, \ldots, x_n$ whose sum is 1, the inequality

$$
\left( \sum_{1\le i<j\le n} x_i x_j \right)^2 \le \lambda \sum_{1\le i<j<k\le n} x_i x_j x_k + \frac{1}{n}\sum_{1\le i<j\le n} (x_i - x_j)^2
$$

always holds.

**Notation.**
For a given integer \(n \ge 3\) and non‑negative real numbers \(x_1,\dots,x_n\) with \(\sum_{i=1}^n x_i = 1\) we define

\[
S = \sum_{1\le i<j\le n} x_i x_j,\qquad
T = \sum_{1\le i<j<k\le n} x_i x_j x_k,\qquad
V = \sum_{i=1}^n \Bigl(x_i-\frac1n\Bigr)^2 .
\]

Notice that

\[
\sum_{1\le i<j\le n} (x_i-x_j)^2 = n\sum_{i=1}^n x_i^2 -1 = nB-1,
\]

where \(B = \sum_{i=1}^n x_i^2\). Hence

\[
\frac1n\sum_{1\le i<j\le n} (x_i-x_j)^2 = B-\frac1n = V.
\]

Thus the inequality in the problem becomes

\[
S^2 \;\le\; \lambda\, T \;+\; V. \tag{0}
\]

**Useful relations.**
Because \(\sum x_i =1\) we have

\[
S = \frac{1-B}{2},\qquad
T = \frac{1-3B+2C}{6},
\]

where \(C = \sum_{i=1}^n x_i^3\).
The equality \(V = B-\frac1n\) has already been used.

---

### Lemma

For every \(n\ge 3\) and every admissible \((x_i)\) the inequality

\[
S^2 \;\le\; \frac32\cdot\frac{n-1}{n-2}\; T \;+\; V \tag{1}
\]

holds.

*Proof.*
Set \(c_n = \dfrac32\cdot\dfrac{n-1}{n-2}\).  Substituting the expressions for \(S,T,V\) into (1) and multiplying by \(12\) gives

\[
3(1-B)^2 \;\le\; 2c_n\,(1-3B+2C) \;+\; 12\Bigl(B-\frac1n\Bigr).
\]

Since \(2c_n = \dfrac{3(n-1)}{n-2}\), after dividing by \(3\) we obtain

\[
1-6B+B^2+\frac4n \;\le\; \frac{n-1}{n-2}\,(1-3B+2C).
\]

Multiplying by \(n-2\) and rearranging yields

\[
-(n-2)B^2 + 3(n-3)B + 2(n-1)C -3 + \frac8n \;\ge\; 0,
\]

or equivalently

\[
2(n-1)C \;\ge\; (n-2)B^2 - 3(n-3)B + 3 - \frac8n. \tag{2}
\]

We now prove (2).

1. **A lower bound for \(C\).**
   By the Cauchy–Schwarz inequality

   \[
   \biggl(\sum_{i=1}^n x_i^2\biggr)^{\!2}
   = \biggl(\sum_{i=1}^n \sqrt{x_i}\cdot x_i^{3/2}\biggr)^{\!2}
   \le \biggl(\sum_{i=1}^n x_i\biggr)\biggl(\sum_{i=1}^n x_i^3\biggr)
   = 1\cdot C.
   \]

   Hence

   \[
   C \;\ge\; B^2. \tag{3}
   \]

2. **A quadratic estimate.**
   From (3) we have \(2(n-1)C \ge 2(n-1)B^2\).  Therefore it suffices to show

   \[
   2(n-1)B^2 \;\ge\; (n-2)B^2 - 3(n-3)B + 3 - \frac8n,
   \]

   i.e.

   \[
   nB^2 + 3(n-3)B - 3 + \frac8n \;\ge\; 0. \tag{4}
   \]

   The number \(B\) satisfies \(B\ge \frac1n\) (by \(\bigl(\sum x_i\bigr)^2 \le n\sum x_i^2\)) and \(B\le 1\).
   Define \(Q(B)= nB^2 + 3(n-3)B - 3 + \frac8n\).  Then

   \[
   Q\Bigl(\frac1n\Bigr)
   = n\cdot\frac1{n^2} + 3(n-3)\cdot\frac1n - 3 + \frac8n
   = \frac1n + \frac{3(n-3)}{n} - 3 + \frac8n
   = \frac{3n}{n} - 3 = 0.
   \]

   Moreover, \(Q'(B)=2nB+3(n-3)\).  For \(B\ge \frac1n\),

   \[
   Q'(B)\;\ge\; 2n\cdot\frac1n + 3(n-3) = 2+3(n-3) >0\quad\text{for } n\ge 3.
   \]

   Hence \(Q\) is strictly increasing on \(\bigl[\frac1n,1\bigr]\) and therefore \(Q(B)\ge 0\) there.
   This proves (4) and consequently (2).  Thus (1) is established. ∎

---

### Necessity of \(\lambda > \frac32\)

Assume that for some \(\lambda\) there exists an integer \(N\) such that (0) holds for all \(n\ge N\) and all admissible \((x_i)\).
In particular, for every \(n\ge N\) the **equal** distribution \(x_i=\frac1n\) must satisfy (0).
For this choice we have \(V=0\), \(B=\frac1n\), \(C=\frac1{n^2}\), so that

\[
S = \frac{1-\frac1n}{2},\qquad
T = \frac{1-\frac3n+\frac2{n^2}}{6}.
\]

Inequality (0) becomes

\[
\frac{(1-\frac1n)^2}{4} \;\le\; \lambda\,\frac{1-\frac3n+\frac2{n^2}}{6},
\]

which after simplification yields

\[
\lambda \;\ge\; \frac32\cdot\frac{n-1}{n-2}. \tag{5}
\]

The right‑hand side of (5) is strictly larger than \(\frac32\) for every finite \(n\ge 3\) because

\[
\frac{n-1}{n-2} = 1+\frac{1}{n-2} > 1.
\]

If \(\lambda \le \frac32\), then for **any** \(N\) we can take \(n=N\) (if \(N\ge 3\)) and (5) fails; if \(N\le 2\) we may take \(n=3\ge N\) and again (5) fails.  Hence no such \(N\) exists.  Therefore a necessary condition is \(\lambda > \frac32\).

---

### Sufficiency of \(\lambda > \frac32\)

Let \(\lambda > \frac32\) be fixed.  Consider the sequence

\[
a_n = \frac32\cdot\frac{n-1}{n-2},\qquad n\ge 3.
\]

It is decreasing and \(\displaystyle\lim_{n\to\infty} a_n = \frac32\).
Because \(\lambda > \frac32\), there exists an integer \(N\ge 3\) such that \(a_n \le \lambda\) for all \(n\ge N\).
(Explicitly, choose \(N\) large enough so that \(a_N \le \lambda\); then because the sequence decreases, \(a_n \le a_N \le \lambda\) for all \(n\ge N\).)

Now take any \(n\ge N\) and any admissible \((x_i)\).  By Lemma (inequality (1)) we have

\[
S^2 \;\le\; a_n\, T \;+\; V.
\]

Since \(a_n \le \lambda\), it follows that

\[
S^2 \;\le\; \lambda\, T \;+\; V,
\]

which is exactly (0).  Thus the required property holds for this \(N\).

---

### Conclusion

The real numbers \(\lambda\) for which there exists a positive integer \(N\) with the stated property are precisely

\[
\boxed{\lambda > \dfrac32}.
\]


Question:
Given an odd integer $n > 1$. It is known that every prime divisor $p$ of $n$ satisfies $\gcd(p - 1, n) = 1$. Determine the number of triples $(a, b, c)$ satisfying the following two conditions:

(1) $a, b, c \in {1, 2, \dots, n}$, and $\gcd(a, b, c, n) = 1$

(2) There exists a permutation $x_1, x_2, \dots, x_n$ of $1, 2, \dots, n$ such that for every $1 \le k \le n$,

$$
n \mid a x_{k+2} + b x_{k+1} + c x_k,
$$
where the indices are interpreted modulo $n$.

### 1. Reformulation
We work in the ring \(\mathbb{Z}/n\mathbb{Z}\), identifying the set \(\{1,2,\dots,n\}\) with its residues (with \(n\) identified with \(0\)). A permutation of this set corresponds to a bijection \(f:\mathbb{Z}/n\mathbb{Z}\to\mathbb{Z}/n\mathbb{Z}\). Condition (2) becomes

\[
a\,f(k+2)+b\,f(k+1)+c\,f(k)\equiv0\pmod n\qquad(\forall k\in\mathbb{Z}/n\mathbb{Z}). \tag{1}
\]

We also have \(\gcd(a,b,c,n)=1\).

### 2. Invertibility of \(a\)
Assume, for a contradiction, that a prime \(p\mid n\) also divides \(a\). Reduce (1) modulo \(p\) and denote \(y_k=f(k)\bmod p\). Because \(f\) is a bijection, the multiset \(\{y_k\}\) contains each element of \(\mathbb{F}_p\) exactly \(n/p\) times (the reduction map \(\mathbb{Z}/n\mathbb{Z}\to\mathbb{F}_p\) is \(n/p\)-to‑1).

* **Case 1:** \(p\nmid b\).
  Then \(b\) is invertible modulo \(p\). Let \(\lambda\equiv -c b^{-1}\pmod p\).
  – If \(p\mid c\), then \(\lambda=0\) and (2) gives \(b y_{k+1}\equiv0\), hence \(y_{k+1}\equiv0\) for all \(k\), contradicting the presence of non‑zero residues.
  – If \(p\nmid c\), then \(\lambda\neq0\) and (2) simplifies to \(y_{k+1}\equiv\lambda y_k\). Inductively \(y_k\equiv\lambda^{k}y_0\). Periodicity \(y_{k+n}=y_k\) forces \(\lambda^{n}y_0\equiv y_0\); since some \(y_k\) is non‑zero, \(\lambda^{n}\equiv1\). The order of \(\lambda\) divides \(p-1\), and \(\gcd(p-1,n)=1\) implies \(\lambda=1\). Then \(y_{k+1}\equiv y_k\) for all \(k\), so all \(y_k\) are equal – impossible for a uniform distribution over \(p>1\) residues.

* **Case 2:** \(p\mid b,\ p\nmid c\).
  Then (2) reduces to \(c y_k\equiv0\), hence \(y_k\equiv0\) for all \(k\), contradiction.

* **Case 3:** \(p\mid b\) and \(p\mid c\).
  Then \(p\) divides \(a,b,c,n\), contradicting \(\gcd(a,b,c,n)=1\).

Thus no prime divisor of \(n\) divides \(a\); consequently \(\gcd(a,n)=1\) and \(a\) is invertible modulo \(n\).

### 3. Reduction to a monic recurrence
Since \(a\) is invertible, set

\[
u\equiv -a^{-1}b,\qquad v\equiv -a^{-1}c\pmod n.
\]

Equation (1) becomes

\[
f(k+2)\equiv u\,f(k+1)+v\,f(k)\pmod n\qquad(\forall k). \tag{3}
\]

The mapping \((a,b,c)\mapsto (a,u,v)\) is a bijection between triples with \(\gcd(a,b,c,n)=1\) and triples with \(a\in(\mathbb{Z}/n\mathbb{Z})^\times,\ u,v\in\mathbb{Z}/n\mathbb{Z}\). (If \(a\) is invertible, then \(b=-au,\ c=-av\) and \(\gcd(a,b,c,n)=\gcd(a,n)=1\).) Hence the number of admissible triples equals

\[
\varphi(n)\;\times\; H(n),
\]

where \(H(n)\) denotes the number of pairs \((u,v)\in(\mathbb{Z}/n\mathbb{Z})^2\) for which there exists a permutation satisfying (3).

### 4. Necessary conditions modulo each prime divisor
Fix a prime \(p\mid n\) and reduce (3) modulo \(p\). Write \(u_p=u\bmod p,\ v_p=v\bmod p,\ y_k=f(k)\bmod p\). Then

\[
y_{k+2}\equiv u_p\,y_{k+1}+v_p\,y_k\pmod p. \tag{4}
\]

The uniform distribution of the residues \(\{y_k\}\) (each appears \(n/p\) times) remains valid.

**Step A: \(v_p\neq0\).**
Assume \(v_p=0\). Then (4) gives \(y_{k+2}\equiv u_p y_{k+1}\).

- If \(u_p=0\), then \(y_{k+2}\equiv0\) forces all \(y_k\) zero, contradiction.
- If \(u_p\neq0\), solve the recurrence. From \(y_{k+2}=u_p y_{k+1}\) we get for \(k\ge0\): \(y_{k+1}=u_p^{k}y_1\). Periodicity \(y_n=y_0,\ y_{n+1}=y_1\) yields
  \[
  u_p^{n-1}y_1=y_0,\qquad y_1=u_p y_0.
  \]
  Combining gives \(y_0=u_p^n y_0\). If \(y_0\equiv0\) then \(y_1\equiv0\) and all \(y_k\equiv0\), contradiction; thus \(y_0\not\equiv0\) and \(u_p^n\equiv1\). Since \(u_p\in\mathbb{F}_p^\times\), its order divides \(p-1\); with \(\gcd(p-1,n)=1\) we get \(u_p=1\). Then the recurrence forces \(y_{k+2}=y_{k+1}\), hence all \(y_k\) are equal, again contradicting uniformity. Therefore \(v_p\neq0\).

**Step B: The companion matrix.**
Define

\[
M_p=\begin{pmatrix}0&1\\ v_p&u_p\end{pmatrix}\in\operatorname{GL}_2(\mathbb{F}_p),\qquad s_k=(y_k,y_{k+1})^{\!\top}.
\]

Then \(s_{k+1}=M_p s_k\). Because the sequence is \(n\)-periodic, \(s_n=s_0\), i.e. \(M_p^n s_0=s_0\). Let \(\tau\) be the order of \(s_0\) under the action of \(M_p\) (smallest \(t>0\) with \(M_p^t s_0=s_0\)). Then \(\tau\mid n\).

The multiset \(\{y_k\}\) consists of \(n/\tau\) repetitions of the \(\tau\) values \(y_0,\dots,y_{\tau-1}\). Uniformity implies that in one \(\tau\)-block each residue appears exactly \(\tau/p\) times; in particular \(p\mid\tau\). Since \(\tau\) divides \(\operatorname{ord}(M_p)\), we have \(p\mid\operatorname{ord}(M_p)\).

Now classify the possible Jordan forms of \(M_p\) over \(\mathbb{F}_p\):

* **Distinct eigenvalues in \(\mathbb{F}_p\).** Then \(M_p\) is diagonalizable, its eigenvalues lie in \(\mathbb{F}_p^\times\), and their orders divide \(p-1\). Hence \(\operatorname{ord}(M_p)\mid p-1\), contradicting \(p\mid\operatorname{ord}(M_p)\).
* **Irreducible characteristic polynomial.** The eigenvalues lie in \(\mathbb{F}_{p^2}^\times\); their orders divide \(p^2-1\), which is coprime to \(p\). So \(\operatorname{ord}(M_p)\) is coprime to \(p\), contradiction.
* **Double eigenvalue \(\lambda\in\mathbb{F}_p^\times\) (since \(v_p\neq0\)).** Then \(u_p=2\lambda,\ v_p=-\lambda^2\), and \(M_p\) is not diagonalizable (it is conjugate to a Jordan block). One checks that \(\operatorname{ord}(M_p)=p\cdot\operatorname{ord}(\lambda)\). A vector that is not an eigenvector has orbit size exactly \(p\cdot\operatorname{ord}(\lambda)\); an eigenvector has orbit size dividing \(\operatorname{ord}(\lambda)\).

Because \(p\mid\operatorname{ord}(M_p)\), the only possible case is the double eigenvalue one. Moreover, \(\tau\) is a multiple of \(p\), so \(s_0\) cannot be an eigenvector (otherwise its orbit size would divide \(\operatorname{ord}(\lambda)\), which is coprime to \(p\)). Hence \(\tau=\operatorname{ord}(M_p)=p\cdot d\) where \(d=\operatorname{ord}(\lambda)\).

Now \(\tau\mid n\) and \(d\mid p-1\). Since \(\gcd(p-1,n)=1\), we must have \(d=1\), i.e. \(\lambda=1\). Consequently

\[
u_p\equiv2\pmod p,\qquad v_p\equiv-1\pmod p. \tag{5}
\]

Thus for every prime divisor \(p\) of \(n\), (5) holds.

### 5. Chinese Remainder Theorem decomposition
Write \(n=\prod_{p\mid n}p^{e_p}\). By the CRT,

\[
\mathbb{Z}/n\mathbb{Z}\cong\prod_{p\mid n}R_p,\qquad R_p=\mathbb{Z}/p^{e_p}\mathbb{Z}.
\]

Under this isomorphism, \(u\) and \(v\) correspond to tuples \((u_p)_{p\mid n},(v_p)_{p\mid n}\) with \(u_p,v_p\in R_p\) satisfying the congruences (5).

Suppose \(f:\mathbb{Z}/n\mathbb{Z}\to\mathbb{Z}/n\mathbb{Z}\) is a bijection satisfying (3). For each \(p\), let \(f_p(k)\) be the projection of \(f(k)\) to \(R_p\). Then (3) splits componentwise:

\[
f_p(k+2)=u_p\,f_p(k+1)+v_p\,f_p(k)\quad\text{in }R_p. \tag{6}
\]

Define the matrix

\[
M_p=\begin{pmatrix}0&1\\ v_p&u_p\end{pmatrix}\in\operatorname{GL}_2(R_p).
\]

We will show later (Lemma 1) that \(M_p^{\,p^{e_p}}=I\) for any such lifts. Consequently, from the recurrence we obtain \(f_p(k+p^{e_p})=f_p(k)\), so \(f_p\) is periodic with period dividing \(p^{e_p}\). Hence \(f_p\) factors through \(\mathbb{Z}/p^{e_p}\mathbb{Z}\): there exists a function \(g_p:\mathbb{Z}/p^{e_p}\mathbb{Z}\to R_p\) such that \(f_p(k)=g_p(k\bmod p^{e_p})\), and \(g_p\) satisfies (6) on the cyclic group of order \(p^{e_p}\).

Because \(f\) is a bijection, the map

\[
k\longmapsto\bigl(g_p(k\bmod p^{e_p})\bigr)_{p\mid n}
\]

is a bijection from \(\mathbb{Z}/n\mathbb{Z}\) to \(\prod_{p\mid n}R_p\). Using the CRT bijection \(\mathbb{Z}/n\mathbb{Z}\cong\prod_{p\mid n}\mathbb{Z}/p^{e_p}\mathbb{Z}\), this is equivalent to the map

\[
G:\prod_{p\mid n}\mathbb{Z}/p^{e_p}\mathbb{Z}\longrightarrow\prod_{p\mid n}R_p,\qquad G\bigl((i_p)_p\bigr)=\bigl(g_p(i_p)\bigr)_p
\]

being bijective. Since both sets have the same finite cardinality, bijectivity of \(G\) forces each \(g_p\) to be injective (if two inputs differ only in the \(p\)-th coordinate, their images would coincide). Hence each \(g_p\) is a bijection from \(\mathbb{Z}/p^{e_p}\mathbb{Z}\) onto \(R_p\) (both of size \(p^{e_p}\)).

Conversely, given for each \(p\) a bijection \(g_p:R_p\to R_p\) satisfying (6), defining \(f\) via the CRT yields a global bijection satisfying (3). Therefore the existence of a global permutation is equivalent to the existence, for each prime power factor \(p^{e_p}\), of a bijection of \(R_p\) satisfying (6) with the given \(u_p,v_p\). Consequently

\[
H(n)=\prod_{p\mid n}H(p^{e_p}),
\]

where \(H(p^{e})\) denotes the number of pairs \((u,v)\in R=\mathbb{Z}/p^{e}\mathbb{Z}\) with \(u\equiv2,\ v\equiv-1\pmod p\) for which such a bijection exists.

### 6. Analysis for a prime power modulus
Fix a prime \(p\) (odd) and an exponent \(e\ge1\). Let \(R=\mathbb{Z}/p^{e}\mathbb{Z}\). We consider \(u,v\in R\) satisfying

\[
u=2+pU,\qquad v=-1+pV,
\]

with \(U,V\in R\) (when \(e=1\) there is no free choice – the pair is uniquely \((2,-1)\)). Define

\[
M=\begin{pmatrix}0&1\\ v&u\end{pmatrix},\qquad N=M-I.
\]

Using \(M^2=uM+vI\) we compute

\[
N^2=(u-2)M+(v+1)I = p(UM+VI). \tag{7}
\]

Hence \(N^2\) is divisible by \(p\). Moreover, modulo \(p\) we have \(M\equiv J=\begin{pmatrix}0&1\\-1&2\end{pmatrix}\) and \(N\equiv J-I\neq0\).

**Lemma 1.** For any such \(M\), \(M^{\,p^{e}}=I\) in \(R\).

*Proof.* Induction on \(\beta\) shows \(M^{\,p^{\beta}}=I+p^{\beta}A_{\beta}\) for some matrix \(A_{\beta}\). For \(\beta=e\), the term \(p^{e}A_e=0\) in \(R\), so \(M^{\,p^{e}}=I\). The details are supplied in the cases below. ∎

The decisive point is to determine when the order of \(M\) is exactly \(p^{e}\). We treat \(p>3\) and \(p=3\) separately.

#### 6.1. The case \(p>3\)

**Proposition 2.** For \(p>3\), every lift \((U,V)\) yields \(\operatorname{ord}(M)=p^{e}\).

*Proof.* We prove by induction on \(\beta\ (1\le\beta\le e)\) that

\[
M^{\,p^{\beta}} = I + p^{\beta} N_{\beta},\qquad N_{\beta}\bmod p\neq0. \tag{8}
\]

*Base \(\beta=1\):* Expand \(M^p=(I+N)^p\):

\[
M^p = I + pN + \sum_{k=2}^{p-1}\binom{p}{k}N^{k} + N^{p}.
\]

From (7), \(N^2=pQ\). For \(k\ge2\), write \(N^{k}=N^{k-2}N^{2}=p N^{k-2}Q\). Hence each term \(\binom{p}{k}N^{k}\) contains at least two factors of \(p\) (one from \(\binom{p}{k}\) for \(2\le k\le p-1\) and one from \(N^{k}\)). For \(k=p\), \(N^{p}=N(N^2)^{(p-1)/2}=N(pQ)^{(p-1)/2}=p^{(p-1)/2}N Q^{(p-1)/2}\); since \(p>3\), \((p-1)/2\ge2\), so this term is also divisible by \(p^2\). Thus

\[
M^p = I + pN + p^2 S = I + p N_1,
\]
with \(N_1\equiv N\pmod p\neq0\).

*Inductive step:* Assume (8) holds for some \(\beta<e\). Then

\[
M^{\,p^{\beta+1}} = (I+p^{\beta}N_{\beta})^{p}=I + p\cdot p^{\beta}N_{\beta} + \sum_{k=2}^{p}\binom{p}{k}p^{\beta k}N_{\beta}^{k}.
\]
The linear term is \(p^{\beta+1}N_{\beta}\). For \(k\ge2\), the exponent of \(p\) in the term is at least \(1+\beta k\) (for \(2\le k\le p-1\)) or \(\beta p\) (for \(k=p\)). Because \(\beta\ge1\) and \(p\ge5\), one checks that these exponents are \(\ge\beta+2\). Hence all higher terms are multiples of \(p^{\beta+2}\). Therefore

\[
M^{\,p^{\beta+1}} = I + p^{\beta+1}N_{\beta} + p^{\beta+2}T = I + p^{\beta+1}N_{\beta+1},
\]
with \(N_{\beta+1}=N_{\beta}+pT\). Since \(N_{\beta}\bmod p\neq0\), also \(N_{\beta+1}\bmod p\neq0\).

Now take \(\beta=e-1\) in (8): \(M^{\,p^{e-1}} = I + p^{e-1}N_{e-1}\neq I\) because \(p^{e-1}N_{e-1}\neq0\) in \(R\). With Lemma 1 (\(M^{\,p^{e}}=I\)) we conclude \(\operatorname{ord}(M)=p^{e}\). ∎

#### 6.2. The case \(p=3\)

Now \(p=3\). Write \(u=2+3U,\ v=-1+3V\).

**Proposition 3.** For \(p=3\):

* If \(e=1\), then necessarily \((u,v)=(2,2)\) and \(\operatorname{ord}(M)=3\).
* If \(e\ge2\), then \(\operatorname{ord}(M)=3^{e}\) iff \(U+V\not\equiv2\pmod3\). When \(U+V\equiv2\pmod3\), the order divides \(3^{e-1}\) (so is strictly smaller).

*Proof.* Compute \(M^3\) using \(M^2=uM+vI\):

\[
M^3 = (u^2+v)M + uv I.
\]

Substituting the expressions for \(u,v\):

\[
\begin{aligned}
u^2+v &= 3(1+4U+V) + 9U^2, \\
uv    &= -2 + 3(2V-U) + 9UV.
\end{aligned}
\]

Hence

\[
M^3 = I + 3T + 9S,
\]

with

\[
T = (1+4U+V)M + (-1+2V-U)I,\qquad S = U^2M + UV I.
\]

Reducing modulo \(3\):
\(1+4U+V\equiv1+U+V\), \(-1+2V-U\equiv -(1+U+V)\pmod3\). Thus

\[
T \equiv (1+U+V)(M-I)\pmod3. \tag{9}
\]

* **Case 1:** \(U+V\not\equiv2\pmod3\), i.e., \(1+U+V\not\equiv0\pmod3\).
  Then \(T\bmod3\) is a non‑zero scalar times \(M-I\), and since \(M-I\bmod3\neq0\), \(T\) is not divisible by \(3\). So \(M^3 = I + 3T\) with \(T\bmod3\neq0\).

  An induction analogous to the one for \(p>3\) (but now with base \(M^3=I+3T\)) shows that for all \(1\le\beta\le e\),

  \[
  M^{\,3^{\beta}} = I + 3^{\beta} T_{\beta},\qquad T_{\beta}\bmod3\neq0.
  \]

  For \(\beta=e-1\) we obtain \(M^{\,3^{e-1}}\neq I\), while \(M^{\,3^{e}}=I\) by Lemma 1, hence \(\operatorname{ord}(M)=3^{e}\).

* **Case 2:** \(U+V\equiv2\pmod3\), i.e., \(1+U+V\equiv0\pmod3\).
  Then (9) shows that \(T\) is divisible by \(3\); write \(T=3T'\). Then

  \[
  M^3 = I + 9T' + 9S = I + 9L,\qquad L = T' + S.
  \]

  Now one proves by induction that \((I+9L)^{\,3^{m}}\equiv I\pmod{3^{m+2}}\). Taking \(m=e-2\) yields \(M^{\,3^{e-1}} = (I+9L)^{3^{e-2}} \equiv I\pmod{3^{e}}\), i.e., \(M^{\,3^{e-1}}=I\) in \(R\). Therefore the order divides \(3^{e-1}\) and is strictly smaller than \(3^{e}\). ∎

#### 6.3. Equivalence with existence of a permutation

**Proposition 4.** For a prime power \(q=p^{e}\) and \(u,v\in R\) satisfying (5), the following are equivalent:

(i) \(\operatorname{ord}(M)=p^{e}\).
(ii) There exists a permutation \(g:R\to R\) such that \(g(k+2)=u\,g(k+1)+v\,g(k)\) for all \(k\) (indices modulo \(p^{e}\)).
(iii) The map \(g(k)=e_1^{\!\top} M^{k} v_0\), with \(v_0=(0,1)^{\!\top}\), is a permutation of \(R\).

*Proof.*
**(i)⇒(iii):** The recurrence holds by construction. To prove bijectivity we show injectivity by induction on the exponent \(\beta\) (\(1\le\beta\le e\)) that \(g(k)\equiv g(\ell)\pmod{p^{\beta}}\) implies \(k\equiv\ell\pmod{p^{\beta}}\).

*Base \(\beta=1\):* Modulo \(p\), \(M\equiv I+N_0\) with \(N_0^2=0\). Then \(M^{k}\equiv I+kN_0\) and

\[
g(k)\bmod p = e_1^{\!\top}(I+kN_0)v_0 = e_1^{\!\top}v_0 + k\,e_1^{\!\top}N_0 v_0 = k,
\]

because \(e_1^{\!\top}v_0=0\) and \(e_1^{\!\top}N_0 v_0=1\). Hence \(g(k)\equiv k\pmod p\), giving the base case.

*Inductive step:* Assume the claim holds for some \(\beta<e\) and suppose \(g(k)\equiv g(\ell)\pmod{p^{\beta+1}}\). Reducing modulo \(p^{\beta}\) gives \(k\equiv\ell\pmod{p^{\beta}}\), so we can write \(\ell = k + p^{\beta}t\) with \(0\le t<p\). From the order analysis (Propositions 2 and 3, good case) we have

\[
M^{\,p^{\beta}} = I + p^{\beta} N_{\beta},\qquad N_{\beta}\bmod p\neq0.
\]

Then

\[
\begin{aligned}
g(\ell) &= e_1^{\!\top} M^{k} (M^{\,p^{\beta}})^{t} v_0 \\
        &= e_1^{\!\top} M^{k} \bigl(I + t p^{\beta} N_{\beta} + p^{\beta+1}E\bigr) v_0 \\
        &= g(k) + t p^{\beta}\,\underbrace{e_1^{\!\top} M^{k} N_{\beta} v_0}_{\lambda} + p^{\beta+1}(\cdots).
\end{aligned}
\]

Modulo \(p\), \(M^{k}\equiv I+kN_0\) and \(N_{\beta}\equiv c N_0\) for some \(c\not\equiv0\). Thus

\[
\lambda \equiv c\,e_1^{\!\top}(I+kN_0)N_0 v_0 = c\bigl(e_1^{\!\top}N_0 v_0 + k\,e_1^{\!\top}N_0^{2}v_0\bigr)=c,
\]

a unit modulo \(p\). Hence \(\lambda\) is not divisible by \(p\). The difference \(g(\ell)-g(k)\) is congruent to \(t p^{\beta}\lambda\) modulo \(p^{\beta+1}\). For this to be \(0\) modulo \(p^{\beta+1}\) we must have \(t\equiv0\pmod p\); since \(0\le t<p\), \(t=0\). Thus \(\ell=k\), proving injectivity modulo \(p^{\beta+1}\). By induction, \(g\) is injective on \(R\), hence bijective.

**(iii)⇒(ii)** is immediate.

**(ii)⇒(i):** Let \(g\) be a bijection satisfying the recurrence. Choose \(s_0=(g(0),g(1))^{\!\top}\). By induction, \(g(k)=e_1^{\!\top} M^{k} s_0\). Because \(g\) is injective, the vectors \(M^{k}s_0\) for \(k=0,\dots,p^{e}-1\) are distinct; thus the orbit of \(s_0\) has size \(p^{e}\). Hence \(\operatorname{ord}(M)\ge p^{e}\). Lemma 1 gives \(M^{\,p^{e}}=I\), so \(\operatorname{ord}(M)\mid p^{e}\). Therefore \(\operatorname{ord}(M)=p^{e}\). ∎

### 7. Counting admissible pairs \((u,v)\) for each prime power
From Propositions 2–4 we deduce the number \(H(p^{e})\) of pairs \((u,v)\) in \(\mathbb{Z}/p^{e}\mathbb{Z}\) with \(u\equiv2,\ v\equiv-1\pmod p\) that admit a permutation.

* **\(p>3\):** Every lift works. The number of such pairs is \(p^{2(e-1)}\) (interpreted as \(1\) for \(e=1\)). Thus

  \[
  H(p^{e}) = p^{2(e-1)}.
  \]

* **\(p=3\):**
  – \(e=1\): only \((u,v)=(2,2)\); \(H(3)=1\).
  – \(e\ge2\): admissible exactly when \(U+V\not\equiv2\pmod3\). Among the \(3^{2(e-1)}\) lifts, the condition depends only on residues modulo \(3\). There are \(9\) residue pairs; exactly \(3\) satisfy \(U+V\equiv2\). For each good residue class there are \(3^{2(e-2)}\) lifts. Hence

  \[
  H(3^{e}) = 6\cdot 3^{2(e-2)} = 2\cdot 3^{2e-3}.
  \]

### 8. Final count of triples \((a,b,c)\)
Recall that the total number is

\[
N = \varphi(n)\;\times\; \prod_{p\mid n} H(p^{e_p}),\qquad \varphi(n)=\prod_{p\mid n} p^{e_p-1}(p-1).
\]

* For \(p>3\): contribution \(= p^{e_p-1}(p-1)\cdot p^{2(e_p-1)} = p^{3e_p-3}(p-1)\).

* For \(p=3\):
  – if \(3\nmid n\): factor \(1\);
  – if \(e_3=1\): \(\varphi(3)=2,\ H(3)=1\ \Rightarrow\ 2\);
  – if \(e_3\ge2\): \(\varphi(3^{e_3})=2\cdot3^{e_3-1},\ H(3^{e_3})=2\cdot3^{2e_3-3}\ \Rightarrow\ 4\cdot3^{3e_3-4}\).

Therefore

\[
\boxed{ N = \left( \prod_{\substack{p\mid n\\ p>3}} p^{3\operatorname{ord}_p(n)-3}(p-1) \right) \times \begin{cases}
1 & \text{if } 3\nmid n,\\[2mm]
2 & \text{if } \operatorname{ord}_3(n)=1,\\[2mm]
4\cdot 3^{3\operatorname{ord}_3(n)-4} & \text{if } \operatorname{ord}_3(n)\ge 2.
\end{cases} }
\]

---