# The 36th Nordic Mathematical Contest Monday, 4 April 2022 ## Solutions ## Problem 1 Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ such that $$ f(f(x) f(1-x))=f(x) \quad \text { and } \quad f(f(x))=1-f(x) $$ for all real $x$. Solution 1. Notice that $f(f(f(x)))=^{2} 1-f(f(x))={ }^{2} f(x)$. This is equation 3 . By substituting $f(x)$ for $x$ in the first equation we get: $$ f(\underline{f(x)})={ }^{1} f(f(\underline{f(x)}) f(1-\underline{f(x)}))={ }^{2} f(f(f(x)) f(f(f(x))))={ }^{3} f(f(f(x)) f(x)) $$ Again we substitute $f(x)$ for $x$ above: $$ f(f(\underline{f(x)}))=f(f(f(\underline{f(x)})) f(\underline{f(x)})) $$ Equation 3 applied on both sides gives us: $$ f(x)=f(f(x) f(f(x))) $$ But this is the same as what we started with so $$ f(x)=f(f(x) f(f(x)))=f(f(x))={ }^{2} 1-f(x) $$ Therefore $f(x)=\frac{1}{2}$, which is a solution. Solution 2. Let first $c$ be a fix point of $f$, that is $f(c)=c$. Then from the second equation we have $$ c=1-c \Rightarrow c=\frac{1}{2} $$ The substitution $y=1-x$ in the first equation shows that $f(1-x)=f(x)$ for any $x$. Now, using this and applying $f$ to the second equation we get $$ f(f(f(x)))=f(1-f(x)))=f(f(x)) $$ thus $f(f(x))$ is a fix point and therefore $f(f(x))=\frac{1}{2}$. Now the second equation gives $f(x)=\frac{1}{2}$. It is easy to check that this is a solution. ## Problem 2 In Wonderland, the towns are connected by roads, and whenever there is a direct road between two towns there is also a route between these two towns that does not use that road. (There is at most one direct road between any two towns.) The Queen of Hearts ordered the Spades to provide a list of all "even" subsystems of the system of roads, that is, systems formed by subsets of the set of roads, where each town is connected to an even number of roads (possibly none). For each such subsystem they should list its roads. If there are totally $n$ roads in Wonderland and $x$ subsystems on the Spades' list, what is the number of roads on their list when each road is counted as many times as it is listed? Solution. The answer is $\frac{1}{2} n x$. Proof: We reformulate the problem in terms of graph theory with the towns being vertices and the roads being edges of a graph $G=(V, E)$. The given information implies that every edge $e \in E$ is part of a cycle. The subgraphs to be counted are those with every valence even, briefly the even subgraphs. Let $N$ be the sum of the numbers of edges in those subgraphs. We can calculate this number by counting for each edge $e \in E$ the even subgraphs of $G$ containing $e$. If $S(e)$ is the set of these graphs, then $N=\sum_{e \in E}|S(e)|$. Now consider for a given $e \in E$ some cycle $c(e)$ containing $e$. For every even subgraph $H$ of $G$ one can define the graph $H^{\prime}$ obtained from $H$ by replacing the set of edges in $H$ that are also edges in $c(e)$ by the set of edges in $c(e)$ that are not edges in $H$. For a given vertex $v \in V$ the following possibilities exist. (i) $c(e)$ does not pass through $v$. (ii) Both edges in $c(e)$ adjacent to $v$ are in $H$. They are then absent from $H^{\prime}$. (iii) None of the edges in $c(e)$ adjacent to $v$ are in $H$. They are then both in $H^{\prime}$. (iv) Exactly one of the edges in $c(e)$ adjacent to $v$ are in $H$. It is then not in $H^{\prime}$ while the other one belongs to $H^{\prime}$. In every case any edge adjacent to $v$ that is not in $c(e)$ is in either none or both of $H$ and $H^{\prime}$. It follows that $H^{\prime}$ is an even subgraph of $G$. Since evidently $H^{\prime \prime}=H$, the total set of even subgraphs of $G$ is thus the union of disjoint pairs $\left\{H, H^{\prime}\right\}$. Exactly one member of each pair belongs to $S(e)$, so $|S(e)|=x / 2$, and $N=\frac{1}{2} n x$. ## Problem 3 Anton and Britta play a game with the set $M=\{1,2,3, \ldots, n-1\}$ where $n \geq 5$ is an odd integer. In each step Anton removes a number from $M$ and puts it in his set $A$, and Britta removes a number from $M$ and puts it in her set $B$ (both $A$ and $B$ are empty to begin with). When $M$ is empty, Anton picks two distinct numbers $x_{1}, x_{2}$ from $A$ and shows them to Britta. Britta then picks two distinct numbers $y_{1}, y_{2}$ from $B$. Britta wins if $$ \left(x_{1} x_{2}\left(x_{1}-y_{1}\right)\left(x_{2}-y_{2}\right)\right)^{\frac{n-1}{2}} \equiv 1 \quad \bmod n $$ otherwise Anton wins. Find all $n$ for which Britta has a winning strategy. Solution. Britta wins if and only if $n$ is prime. If $n$ is not prime, then Anton can add any prime divisor $p