# $2^{\text {ND }}$ European Mathematical Cup
$7^{\text {th }}$ December 2013-15 $5^{\text {st }}$ December 2013
Junior Category ## Problems and Solutions Problem 1. For a positive integer $m$ let $m$ ? be the product of first $m$ prime numbers. Determine if there exist positive integers $m$ and $n$ with the following property: $$ m ?=n(n+1)(n+2)(n+3) $$ (Matko Ljulj) Solution. Such numbers don't exist. Let's assume the contrary i.e. there are such $m$ and $n$. We can note that there is only one prime divisible by 2 and that it 2 itself thus $m$ ? isn't divisble by 4 . On the other hand, the product $n(n+1)(n+2)(n+3)$ is product of 4 consecutive integers so two of them are even making the product divisble by 4 . Thus equality $m ?=n(n+1)(n+2)(n+3)$ gives us a contradiction as $L H S$ is not divisble by 4 while $R H S$ is. Problem 2. Let $P$ be a point inside a triangle $A B C$. A line through $P$ parallel to $A B$ meets $B C$ and $C A$ at points $L$ and $F$, respectively. A line through $P$ parallel to $B C$ meets $C A$ and $B A$ at points $M$ and $D$ respectively, and a line through $P$ parallel to $C A$ meets $A B$ and $B C$ at points $N$ and $E$ respectively. Prove $$ (P D B L) \cdot(P E C M) \cdot(P F A N)=8 \cdot(P F M) \cdot(P E L) \cdot(P D N) $$ where $(X Y Z)$ and $(X Y Z W)$ denote the area of the triangle $X Y Z$ and the area of quadrilateral $X Y Z W$. (Steve Dinh) Solution. ![](https://cdn.mathpix.com/cropped/2024_06_05_3d3d2e81fc81180a6b99g-1.jpg?height=486&width=877&top_left_y=1870&top_left_x=498) Let's denote the areas as on the sketch. The problem is equivalent to $$ U \cdot V \cdot W=X \cdot Y \cdot Z $$ Let $x$ and $y$ be lengths of altitudes from $I$ and $D$ in the triangle $B I D$ and let $a$ and $b$ be lenghts of sides $B I$ and $B D$. We can deduce $$ \begin{gathered} X=(P E D)=\frac{1}{2} \cdot a \cdot y \cdot \frac{B C}{B A} \\ Z=(P I H)=\frac{1}{2} \cdot b \cdot x \cdot \frac{B A}{B C} \text { and } \end{gathered} $$ $$ U=(B I D)=\frac{1}{2} \cdot a \cdot x=\frac{1}{2} \cdot b \cdot y $$ This gives $U^{2}=X \cdot Z$. Analogously we get $W^{2}=Y \cdot Z$ and $V^{2}=X \cdot Y$. Multiplying all three equalities we get the desired equation. Second solution. Let's denote the areas of triangles $P E L, P F M, P D N$ as $P_{A}, P_{B}, P_{C}$ respectively and let's denote the areas of quadrilaterals $P F A N, P D B L, P E C M$ as $Q_{A}, Q_{B}, Q_{C}$ respectively. We want to prove $Q_{A} Q_{B} Q_{C}=8 P_{A} P_{B} P_{C}$. Triangles $P E L, P F M$, and $P D N$ are similar to the triangle $A B C$ (they have respective pairs of sides on parallel lines). Let's denote the respective similarity coefficients as $k_{A}, k_{B}, k_{C}$. As triangles $P E L, P F M$, and $P D N$ are in the interior of $A B C$, all those coefficients are less than 1 . Triangle $E N B$ is similar to the triangle $A B C$. Its similarity coefficient is $$ \frac{E N}{A C}=\frac{E F+F N}{A C}=\frac{E F}{A C}+\frac{F N}{A C}=k_{A}+k_{C} $$ From all these similarity relations we get area relations. Namely: $$ \begin{aligned} & P_{A}: P_{B}=\left(P_{A}:(A B C)\right):\left(P_{B}:(A B C)\right)=\left(\frac{k_{A}}{k_{B}}\right)^{2} \Longrightarrow P_{A}=\left(\frac{k_{A}}{k_{B}}\right)^{2} P_{B} \\ & P_{C}: P_{B}=\left(P_{C}:(A B C)\right):\left(P_{B}:(A B C)\right)=\left(\frac{k_{C}}{k_{B}}\right)^{2} \Longrightarrow P_{C}=\left(\frac{k_{C}}{k_{B}}\right)^{2} P_{B} \end{aligned} $$ Using this we get: $$ \begin{gathered} \left(P_{A}+P_{C}+Q_{B}\right): P_{B}=(E N B):(P F M)=\left(k_{A}+k_{C}\right)^{2}:\left(k_{B}\right)^{2} \\ \Longrightarrow P_{A}+P_{C}+Q_{B}=\frac{k_{A}^{2}+2 k_{A} k_{C}+k_{C}^{2}}{k_{B}^{2}} P_{B}=\frac{k_{A}^{2}}{k_{B}^{2}} P_{B}+\frac{2 k_{A} k_{C}}{k_{B}^{2}} P_{B}+\frac{k_{C}^{2}}{k_{B}^{2}} P_{B}=P_{A}+\frac{2 k_{A} k_{C}}{k_{B}^{2}} P_{B}+P_{C} \\ \Longrightarrow Q_{B}=\frac{2 k_{A} k_{C}}{k_{B}^{2}} P_{B} \end{gathered} $$ Similary by the same process applied to $F L C$ and $M D A$ we get $Q_{C}=\frac{2 k_{B} k_{A}}{k_{C}^{2}} P_{C}$ i $Q_{A}=\frac{2 k_{C} k_{B}}{k_{A}^{2}} P_{A}$. Multiplying what we got we have $$ Q_{A} Q_{B} Q_{C}=\frac{2 k_{C} k_{B}}{k_{A}^{2}} P_{A} \frac{2 k_{A} k_{C}}{k_{B}^{2}} P_{B} \frac{2 k_{B} k_{A}}{k_{C}^{2}} P_{C}=8 \frac{k_{A}^{2} k_{B}^{2} k_{C}^{2}}{k_{A}^{2} k_{B}^{2} k_{C}^{2}} P_{A} P_{B} P_{C}=8 P_{A} P_{B} P_{C} $$ Q.E.D. Problem 3. We are given a combination lock consisting of 6 rotating discs. Each disc consists of digits $0,1,2, \ldots, 9$, in that order (after digit 9 comes 0 ). Lock is opened by exactly one combination. A move consists of turning one of the discs one digit in any direction and the lock opens instantly if the current combination is correct. Discs are initially put in the position 000000 , and we know that this combination is not correct. a) What is the least number of moves necessary to ensure that we have found the correct combination? b) What is the least number of moves necessary to ensure that we have found the correct combination, if we know that none of the combinations $000000,111111,222222, \ldots, 999999$ is correct? (Ognjen Stipetić, Grgur Valentić) Solution. We will solve the subproblems seperately. a) In order to ensure that we have discovered the code we need to check all but one of the combinations (as otherwise all unchecked codes can be the correct combination). Total number of combinations is $10^{6}$ (as each of the 6 discs consists of 10 digits). As we are given that 000000 is not the correct combination we require at least $10^{6}-2$ moves. We will now prove that there is a sequence of $10^{6}-2$ moves each checking a different combination. We will prove this by induction on the number of wheels where the case $n=6$ is given in the problem. Claim: For a lock of $n$ wheels and for any starting combination of the wheels $\left(a_{1} a_{2} \ldots a_{n}\right)$ there is a sequence of moves checking all $10^{6}$ combinations exactly once, for all $n \in \mathbb{N}$. BASIS: For $n=1$ and for the starting combination (a), we consider the sequence of moves $$ a \rightarrow a+1 \rightarrow a+2 \rightarrow \ldots \rightarrow 9 \rightarrow 0 \rightarrow 1 \rightarrow \ldots \rightarrow a-1 $$ Assumption: The induction claim is valid for some $n \in \mathbb{N}$. STEP: We will prove that the claim holds for $n+1$ as well. We consider an arbitrary starting state $\left(a_{1} a_{2} \ldots a_{n} a_{n+1}\right)$. By the induction hypothesis there is a sequence of moves such that starting from this state we can check all the states showing $a_{n+1}$ on the last disc. Let this sequence of moves end with the combination $\left(b_{1} b_{2} \ldots b_{n} a_{n+1}\right)$. Now we make the move $\left(b_{1} b_{2} \ldots b_{n} a_{n+1}\right) \rightarrow\left(b_{1} b_{2} \ldots b_{n} a_{n+1}+1\right)$ (if $a_{n+1}$ is 9 , then we turn the disc to show 0 ). We continue in the same way applying the induction hypothesis on first $n$ discs and the rotation the $n+1$-st disc. This way we get the sequence of moves $$ \begin{gathered} \left(a_{1} a_{2} \ldots a_{n} a_{n+1}\right) \rightarrow\left(b_{1} b_{2} \ldots b_{n} a_{n+1}\right) \rightarrow\left(b_{1} b_{2} \ldots b_{n} a_{n+1}+1\right) \\ \quad \rightarrow\left(c_{1} c_{2} \ldots c_{n} a_{n+1}+1\right) \rightarrow\left(c_{1} c_{2} \ldots c_{n} a_{n+1}+2\right) \\ \cdots\left(j_{1} j_{2} \ldots j_{n} a_{n+1}-2\right) \rightarrow\left(j_{1} j_{2} \ldots j_{n} a_{n+1}-1\right) \end{gathered} $$ This sequence checks each combination exactly once finishing the induction and proving our claim. b) As in the a) part, we conclude that we have to check all the combinations apart from 000000, 111111, ..., 999999 and we can be sure as to what is the solution before the move checking the last combination. We denote the combination as black if the sum of its digits is even and white if that sum is odd. We can notice that all the combinations $000000,111111, \ldots, 999999$ are black and by each move we swap the color of the current combination. Number of black combinations all of which we need to check at least once is $\frac{10^{6}}{2}-10$ while number of such white combinations is $\frac{10^{6}}{2}$. As we are checking white combinations every second move, in order to check all $\frac{10^{6}}{2}$ white combination swe need at least $2 \frac{10^{6}}{2}-1=10^{6}-1$ moves, thus we need at least $10^{6}-2$ moves to find the correct combination. An example doing this in $10^{6}-2$ moves has been given in part a). Problem 4. Let $a, b, c$ be positive real numbers satisfying $$ \frac{a}{1+b+c}+\frac{b}{1+c+a}+\frac{c}{1+a+b} \geqslant \frac{a b}{1+a+b}+\frac{b c}{1+b+c}+\frac{c a}{1+c+a} $$ Prove $$ \frac{a^{2}+b^{2}+c^{2}}{a b+b c+c a}+a+b+c+2 \geqslant 2(\sqrt{a b}+\sqrt{b c}+\sqrt{c a}) $$ (Dimitar Trenevski) Solution. We start with the given condition: $$ \begin{gathered} \frac{a}{1+b+c}+\frac{b}{1+c+a}+\frac{c}{1+a+b} \geqslant \frac{a b}{1+a+b}+\frac{b c}{1+b+c}+\frac{c a}{1+c+a} \Longleftrightarrow \\ \frac{a+a b+b c}{1+b+c}+\frac{b+b c+b a}{1+c+a}+\frac{c+c a+c b}{1+a+b} \geqslant \frac{a b+a c+b c}{1+a+b}+\frac{b c+a b+b c}{1+b+c}+\frac{c a+b c+a b}{1+c+a} \Longleftrightarrow \\ \frac{a(1+b+c)}{1+b+c}+\frac{b(1+c+a)}{1+c+a}+\frac{c(1+a+b)}{1+a+b} \geqslant \frac{a b+b c+c a}{1+a+b}+\frac{a b+b c+c a}{1+b+c}+\frac{a b+b c+c a}{1+c+a} \Longleftrightarrow \\ a+b+c \geqslant(a b+b c+c a)\left(\frac{1}{1+a+b}+\frac{1}{1+b+c}+\frac{1}{1+c+a}\right) \end{gathered} $$ Now using Cauchy-Schwarz inequality we get: $$ \left(\frac{1}{1+a+b}+\frac{1}{1+b+c}+\frac{1}{1+c+a}\right)(c(1+a+b)+a(1+b+c)+b(1+c+a)) \geqslant(\sqrt{a}+\sqrt{b}+\sqrt{c})^{2} $$ Combining the last two inequalities we get: $$ \begin{gathered} (a+b+c)(a+b+c+2(a b+b c+c a)) \geqslant \\ \geqslant(a b+b c+c a)\left(\frac{1}{1+a+b}+\frac{1}{1+b+c}+\frac{1}{1+c+a}\right)(a+b+c+2(a b+b c+c a))= \\ =(a b+b c+c a)\left(\frac{1}{1+a+b}+\frac{1}{1+b+c}+\frac{1}{1+c+a}\right)(c(1+a+b)+a(1+b+c)+b(1+c+a)) \geqslant \\ \geqslant(a b+b c+c a)(\sqrt{a}+\sqrt{b}+\sqrt{c})^{2} \end{gathered} $$ which now by some algebraic manipulation gives: $$ \begin{gathered} (a+b+c)(a+b+c+2(a b+b c+c a)) \geqslant(a b+b c+c a)(\sqrt{a}+\sqrt{b}+\sqrt{c})^{2} \Longleftrightarrow \\ (a+b+c)^{2}+2(a+b+c)(a b+b c+c a) \geqslant(a b+b c+c a)(a+b+c+2(\sqrt{a b}+\sqrt{b c}+\sqrt{c a})) \Longleftrightarrow \\ \left(a^{2}+b^{2}+c^{2}\right)+(2(a+b+c)+2)(a b+b c+c a) \geqslant(a b+b c+c a)(a+b+c+2(\sqrt{a b}+\sqrt{b c}+\sqrt{c a})) \Longleftrightarrow \\ \frac{a^{2}+b^{2}+c^{2}}{a b+b c+c a}+a+b+c+2 \geqslant 2(\sqrt{a b}+\sqrt{b c}+\sqrt{c a}) \end{gathered} $$ where the last inequality is exactly the one we wanted to prove. Time allowed: 240 minutes. Each problem is worth 10 points. Calculators are not allowed. ## $2^{\text {ND }}$ European Mathematical CuP $7^{\text {th }}$ December 2013-15 $5^{\text {st }}$ December 2013
Senior Category ## Problems and Solutions Problem 1. In each field of a table there is a real number. We call such $n \times n$ table silly if each entry equals the product of all the number in the neighbouring fields. a) Find all $2 \times 2$ silly tables. b) Find all $3 \times 3$ silly tables. (Two fields of a table are neighbouring if they share a common side.) (Borna Vukorepa) Solution. We solve the subproblems separately. a) Denote the numbers in the table as on the picture: ![](https://cdn.mathpix.com/cropped/2024_06_05_3d3d2e81fc81180a6b99g-5.jpg?height=98&width=134&top_left_y=1196&top_left_x=1007) By the problem condition we have the following: $$ \begin{aligned} & a=b c \\ & b=a d \\ & c=a d \\ & d=b c \end{aligned} $$ From here we can see $a=b c=d$ and $b=a d=c$. When we apply this to the upper relations we get $a=b^{2}$ and $b=a^{2}$ and so $a=b^{2}=a^{4} \Longleftrightarrow a(a-1)\left(a^{2}+a+1\right)=0$. The real solutions to this problem are $a=0$ and $a=1$. Now we can see that all $2 \times 2$ silly tables are those with all element equal and furthermore equal to zero or one. b) Denote by $a, b, c, d$ the elements in the table which have exactly three neighbours. We denote the remaining elements in terms of these and get the following table: | $a b$ | $a$ | $a d$ | | :---: | :---: | :---: | | $b$ | $a b c d$ | $d$ | | $b c$ | $c$ | $c d$ | Let's assume that $a b c d=0$. This implies that the middle element is zero which further implies all its neighbours are zero and consequently every element in the table is zero. And thus only silly table under in this case is all zeros table. Now assume that $a b c d \neq 0$, i.e. none of the table elements is equal to zero. Using the remaining conditions we get: $$ a=(a b)(a b c d)(a d)=a^{3} b^{2} d^{2} c \Longleftrightarrow a^{2} b^{2} d^{2} c=1 $$ Analogously we get $a^{2} b^{2} c^{2} d=1, a^{2} c^{2} d^{2} b=1$ i $b^{2} c^{2} d^{2} a=1$ (we are allowed to divide by $a, b, c, d$ as they are all non-zero). Equating the $L H S \mathrm{~s}$ of these equations we get $a=b=c=d$. Inserting this in any of these equations we get $a^{7}=1 \Longrightarrow a=1$. Thus all $3 \times 3$ silly tables are all ones and all zeros tables. Problem 2. Palindrome is a sequence of digits which doesn't change if we reverse the order of its digits. Prove that a sequence $\left(x_{n}\right)_{n=0}^{\infty}$ defined as $$ x_{n}=2013+317 n $$ contains infinitely many numbers with their decimal expansions being palindromes. (Stijn Cambie) First solution. We will prove the following lemma providing two proofs: Lema 1. There is infinitely many numbers divisible with 317 with their decimal expansions consisting only of ones. Proof. Considering the sequence $1,11,111, \ldots$ consisting of infinitely many numbers. This numbers have some residues modulo 317. By The Pigeonhole Principle there are at least two numbers in this sequence with the same residue modulo 317. Let the smaller of these two have $l$ digits and larger $k$. Their difference is $$ \underbrace{111 \ldots 1}_{k \text { times }}-\underbrace{111 \ldots 1}_{l \text { times }}=\underbrace{111 \ldots 1}_{(k-l) \text { times }} \underbrace{000 \ldots 0}_{l \text { times }} $$ divisible by 317. It will also remain divisible by 317 if we divide it by $10^{l}$ (as 10 and 317 are coprime). This way we get a number consisting only of ones divisible by 317 . Let's denote the number of its digits by $k$. We get infinitely many such numbers by considering numbers consisting of $k, 2 k, 3 k, \ldots$ ones. Proof. As 317 is prime, and as it is coprime with 10 by Fermat's Little Theorem $$ 10^{316} \equiv 1(\bmod 317) \Longrightarrow 317 \mid 10^{316 m}-1, \forall m \in \mathbb{Z}, m \geqslant 1 $$ As 9 is coprime with 317 as well, numbers of the form $\frac{1}{9}\left(10^{316 m}-1\right), m \in \mathbb{Z}, m \geqslant 1$ have the property we desire. Continuing with the solution we can note that some integer $m$ is in the sequence $\left(x_{n}\right)_{n=0}^{\infty}$ if and only if $m \geqslant 2013$ and $m \equiv 2013 \equiv 111(\bmod 317)$. Let $\left(y_{n}\right)_{n=0}^{\infty}$ be a sequence of infinitely many positive integers with their decimal expansions consisting only of ones and each being divisible by 317 (we are using our lemma here). Now numbers $$ 1000 y_{n}+111 $$ are in the sequence (as they have the remainder 111 modulo 317) and their decimal expansions are palindromes. Thus there is infinitely many members of the sequence $\left(x_{n}\right)_{n=0}^{\infty}$ whose decimal expansions are palindromes. Second solution. We will prove the generalised version of the problem for the sequence $\left(x_{n}\right)_{n=0}^{\infty}$ defined as $x_{n}=a+n b$, where $a, b$ are arbitrary positive integers with the property that $b$ is coprime with 10 . The problem is a special case of this for $a=2013$ i $b=317$. We define the sequence $\left(y_{n}\right)_{n=0}^{\infty}$ in the following way: $y_{n}=10^{n \varphi(b)}$. Using The Euler's Theorem, $y_{n} \equiv 1$ (mod b). Considering the number $1+y_{n}+y_{n}^{2}+\ldots y_{n}^{a-1}$, its decimal expansion is: $$ 1 \underbrace{000 \ldots 0}_{n \varphi(b)-1 \text { times }} 1 \underbrace{000 \ldots 0}_{n \varphi(b)-1 \text { times }} \cdots 1 \underbrace{000 \ldots 0}_{n \varphi(b)-1 \text { times }} 1 $$ where the digit one is repeated $a$ times. It is clear now that the decimal expansion of this number is a palindrome. On the other hand $1+y_{n}+y_{n}^{2}+\ldots y_{n}^{a-1} \equiv 1+1+\ldots 1=a(\bmod b)$, so this number is in the sequence $\left(x_{n}\right)_{n=0}^{\infty}$, for each number $n$. Thus we have found infinitely many members of the sequence $\left(x_{n}\right)_{n=0}^{\infty}$ with their decimal expansions being palindromes as we wanted. Problem 3. We call a sequence of $n$ digits one or zero a code. Subsequence of a code is a palindrome if it is the same after we reverse the order of its digits. A palindrome is called nice if its digits occur consecutively in the code. (Code (1101) contains 10 palindromes, of which 6 are nice.) a) What is the least number of palindromes in a code? b) What is the least number of nice palindromes in a code? (Ognjen Stipetić) Solution. We will consider the two subproblems separately: a) Consider any code. Assume there is $k$ digits one and $n-k$ digits zero. We now transform this code into $$ \underbrace{111 \ldots 1}_{k \text { puta }} \underbrace{000 \ldots 0}_{n-k \text { puta }} $$ by preserving the order among same digits. Lets note that each palindrome consisting of same digits is in the initial code if and only if it is in the transformed code. The transformed code doesn't have a palindrome not consisting of same digits and thus the transformed code has less or equal palindromes than the initial one. Thus we conclude that it is enough to consider only the codes starting with $k$ digits one and ending in $n-k$ zeros, for some $k \in\{0,1, \ldots n\}$. Let us fix a $k \in\{0,1, \ldots n\}$. The code consisting of $k$ ones and $n-k$ zeros has $2^{k}-1+2^{n-k}-1=2^{k}+2^{n-k}-2$ palindromes. We now seek $k$ which minimizes this expression. If $n$ is even $(n=2 m)$, by the AM-GM inequality $2^{k}+2^{n-k} \geqslant 2 \cdot \sqrt{2^{k+n-k}}=2^{m}+2^{m} \Longrightarrow$ the least possible number of palindromes in the code with $2 m$ digits is $2^{m}+2^{m}-2=2^{m+1}-2$, and this number is clearly attained for the code with $m$ digits one and ending in $m$ digits zero. If $n$ is odd $(n=2 m+1)$ we have the following inequality for each $k \in\{0,1, \ldots m-1\}$ : $$ 2^{k}+2^{n-k}>2^{k+1}+2^{n-k-1}\left(\Longleftrightarrow 2^{n-k-1}>2^{k}\right) $$ From this we also get $2^{k}+2^{n-k-1}<2^{k-1}+2^{n-k+1}$ for all $k \in\{m+1, m+2, \ldots 2 m+1\}$. So: $$ 2^{0}+2^{n}>2^{1}+2^{n-1}>\ldots>2^{m}+2^{m+1}=2^{m+1}+2^{m}<2^{m+2}+2^{m-1}<\ldots<2^{n}+2^{0} $$ Now it is clear that the least number of palindromes in the code with $2 m+1$ digits is $2^{m}+2^{m+1}-2$ and this number is attained by the code of $m$ digits one and $m+1$ digits zero. b) For $n=1$ we clearly see that the answer is 1 . From now on we assume $n \geqslant 2$. As well for simplicity of the write-up we will not consider the one-digit palindromes as nice as we know that each code of $n$ digits consists of $n$ one-digit palindromes, each of which is nice. So we will find the smallest possible number of multi-digit nice palindromes and we will add $n$ to this number to get the desired solution. As a last remark: in this part of the solution for brevity we will denote as palindromes only those that are nice by the definitions in the problem statement. Code consisting of $n$ digits 1 contains one $n$-digit palindrome, two $(n-1)$-digit palindromes, $\ldots, n-2$ three digit palindromes and $n-1$ two digit palindromes. After summing up we get that this code has $\frac{n(n-1)}{2}$ palindromes. Analogously the code consisting of $n$ digits 0 contains the same number of palindromes. We now consider the code which contains at least one digit one and at least one digit zero. Then each digit 1 except the rightmost one is the start of at least one palindrome (the sequence of digits starting with it and ending in the first digit one to the right of it is of the form $100 \ldots 01$ and is thus a palindrome). Analogously we conclude that each digit 0 apart from the rightmost one is a start of at least one palindrome. As we have at least one digit 1 and one digit 0 we conclude that each code consists of at least $n-2$ palindromes (where we have deducted 2 for the rightmost digit 1 and 0 ). By induction on $n$ we will show that for each $n \in \mathbb{N}, n \geqslant 2$ we can find a code with exactly $n-2$ palindromes. We can note that for $n=2,3,4$ this is possible as the examples are (10), (101), (1101). Now let's assume that the induction claim holds for some $n \in \mathbb{N}, n \geqslant 4$, and let $\left(x_{1} \ldots x_{n}\right)$ be a code with exactly $n-2$ palindromes. That code is certainly not $(011 \ldots 1)$ or $(100 \ldots 0)$ (similarly as in the case with all digits equal we conclude that these codes have $\frac{(n-1)(n-2)}{2}>n-2$ palindromes). We now that each of the digits one/zero apart from the rightmost ones is the start of at least one palindrome. In order for total number of palindromes to be $n-2$ all such digits are starts of exactly one palindrome. As $\left(x_{1} \ldots x_{n}\right) \neq(011 \ldots 1)$ and $\left(x_{1} \ldots x_{n}\right) \neq(100 \ldots 0)$, digit $x_{1}$ is not the rightmost digit one $/$ zero $\Longrightarrow x_{1}$ is the start of exactly one palindrome. We now show that we can choose a digit $x_{0}$ such that $\left(x_{0} x_{1} x_{2} \ldots x_{n}\right)$ contains exactly $n-1$ palindromes. As there are $n-2$ palindromes $\left(x_{1} x_{2} \ldots x_{n}\right)$ we need to show that we can choose $x_{0}$ such that $x_{0}$ is a start of exactly one palindrome in $\left(x_{0} x_{1} \ldots x_{n}\right)$. We know that $x_{0}$ is a start of at least one palindrome so we actually only have to show it is a start of at most one palindromes. Let's consider to which palindromes can $x_{0}$ be a start: - $\left(x_{0} x_{1}\right)$ is a palindrome $\Longleftrightarrow x_{0}=x_{1}$ - $\left(x_{0} x_{1} x_{2}\right)$ is a palindrome $\Longleftrightarrow x_{0}=x_{2}$ - $\left(x_{0} x_{1} x_{2} \ldots x_{k} x_{k+1}\right)$ is a palindrome, for some $k \in\{2,3,4, \ldots, n-1\} \Longleftrightarrow x_{0}=x_{k+1}$ and $\left(x_{1} x_{2} \ldots x_{k}\right)$ is a palindrome As there is exactly one palindrome for which $x_{1}$ is the start we conclude there is at most one palindrome such that $x_{0}$ is its start and it has the form as in the third case above. Thus there are at most three palindromes to which $x_{0}$ can be the first digit as we have two options for the choice of $x_{0} \in\{0,1\}$. Thus, by The Pigeonhole Principle we can choose a digit such that $x_{0}$ is a start of at most one palindrome, as desired. Now using this and the remarks given before we have shown that the smallest possible number of nice palindromes with $n$ digits is 1 (for $n=1$ ) and $2 n-2$ (for $n \geqslant 2$ ). Problem 4. Given a triangle $A B C$ let $D, E, F$ be orthogonal projections from $A, B, C$ to the opposite sides respectively. Let $X, Y, Z$ denote midpoints of $A D, B E, C F$ respectively. Prove that perpendiculars from $D$ to $Y Z$, from $E$ to $X Z$ and from $F$ to $X Y$ are concurrent. (Matija Bucić) First solution. Let $H$ be the orthocenter of the triangle $A B C$. We denote the midpoint of $E F$ as $P$. As $P Z$ is a midline of the triangle $C E F$ we have $P Z \| A C$, and as $Y H$ is perpendicular to $A C$, we get that $Y H$ is perpendicular to $P Z$. Analogously we conclude that the line $Z H$ is perpendicular to $P Y$, so $H$ has to be the orthocenter of the triangle $P Y Z$. From this we can deduce that the line $P H$ is perpendicular to $Y Z$, and thus $P H$ is parallel to the line perpendicular to $Y Z$ which passes through $D$. Now denote as $N$ the tangency point of the incircle of the triangle $D E F$ with its side $E F$. Let $N^{\prime}$ be the point symmetric to $N$ with respect to $H$ and let $M$ be the tangency point of the $D$-excircle of the triangle $D E F$ with the side $E F$. As $P$ is the midpoint of $\overline{N M}$ and as is $H$ the midpoint of $N N^{\prime}$, we have that $P H$ is parallel to $N^{\prime} M$. As we know that $M$ is the map of the point $N^{\prime}$ under the homothety with centre $D$ which maps the incircle to excircle of the triangle $D E F$, we can conclude that $D, N^{\prime}$ and $M$ are collinear. We can now conclude that the line perpendicular to $Y Z$ passing through $D$ is parallel to $P H$ while this line is parallel to $N^{\prime} M$. As $D$ lies on $N^{\prime} M$ we conclude that $D M$ is the line through $D$ perpendicular to $Y Z$. Analogously we can conclude that perpendiculars from $E$ to $X Z$ and from $F$ to $X Y$ are lines joining vertices with the corresponding excircle tangency point of the triangle $D E F$. Using the Ceva's Theorem gives us the result. Remark: The intersection of the lines connecting the vertices of the triangle respective tangency points intersect in the point which is called Nagel's point of the triangle (so we have proved that the three lines in the problem intersect in the Nagel's point of the triangle $D E F$ ). ![](https://cdn.mathpix.com/cropped/2024_06_05_3d3d2e81fc81180a6b99g-8.jpg?height=1045&width=1288&top_left_y=965&top_left_x=384) Second solution. By applying The Carnot's Theorem to the triangle $X Y Z$ and points $D, E, F$, three lines in the problem are concurrent if and only if: $$ F X^{2}-F Y^{2}+D Y^{2}-D Z^{2}+E Z^{2}-E X^{2}=0 $$ In the triangle $A F D$ and $E F B$ lines $\overline{F X}$ and $\overline{F Y}$ are medians, so $$ \begin{aligned} & F X^{2}=\frac{1}{4}\left(2 A F^{2}+2 F D^{2}-A D^{2}\right) \\ & F Y^{2}=\frac{1}{4}\left(2 F B^{2}+F E^{2}-E B^{2}\right) \end{aligned} $$ Noting that the other sides on the $L H S$ of (1) are medians in the respective triangles we deduce: $$ \begin{gathered} F X^{2}-F Y^{2}+D Y^{2}-D Z^{2}+E Z^{2}-E X^{2}= \\ \frac{1}{4}\left[\left(2 A F^{2}+2 F D^{2}-A B^{2}\right)-\left(2 F B^{2}+2 F E^{2}-E B^{2}\right)+\right. \\ +\left(2 D B^{2}+2 D E^{2}-E B^{2}\right)-\left(2 D C^{2}+2 D F^{2}-C Y^{2}\right)+ \\ \left.+\left(2 E C^{2}+2 E F^{2}-C F^{2}\right)-\left(2 E A^{2}+2 E D^{2}-A D^{2}\right)\right]= \\ \frac{1}{2}\left(A F^{2}-F B^{2}+D B^{2}-D C^{2}+E C^{2}-E A^{2}\right) \end{gathered} $$ From right-angled triangles $A F C$ and $F B C$ we get: $$ A F^{2}-F B^{2}=\left(A C^{2}-F C^{2}\right)-\left(B C^{2}-F C^{2}\right)=A C^{2}-B C^{2} $$ Applying this analogously to triangles $A E B, E B C, A D C, A D B$ we get: $$ \begin{gathered} F X^{2}-F Y^{2}+D Y^{2}-D Z^{2}+E Z^{2}-E X^{2}= \\ \frac{1}{2}\left(A F^{2}-F B^{2}+D B^{2}-D C^{2}+E C^{2}-E A^{2}\right)= \\ \frac{1}{2}\left(A C^{2}-B C^{2}+A B^{2}-A C^{2}+B C^{2}-A B^{2}\right)=0 \end{gathered} $$ Q.E.D.