{"year": "2017", "tier": "T3", "problem_label": "1", "problem_type": null, "exam": "BalticWay", "problem": "Let $a_{0}, a_{1}, a_{2}, \\ldots$ be an infinite sequence of real numbers satisfying $\\frac{a_{n-1}+a_{n+1}}{2} \\geq a_{n}$ for all positive integers $n$. Show that\n\n$$\n\\frac{a_{0}+a_{n+1}}{2} \\geq \\frac{a_{1}+a_{2}+\\ldots+a_{n}}{n}\n$$\n\nholds for all positive integers $n$.", "solution": "From the inequality $\\frac{a_{n-1}+a_{n+1}}{2} \\geq a_{n}$ we get $a_{n+1}-a_{n} \\geq a_{n}-a_{n-1}$. Inductively this yields that $a_{l+1}-a_{l} \\geq a_{k+1}-a_{k}$ for any positive integers $l>k$, which rewrites as\n\n$$\na_{l+1}+a_{k} \\geq a_{l}+a_{k+1}\n$$\n\nNow fix $n$ and define $b_{m}=a_{m}+a_{n+1-m}$ for $m=0, \\ldots n+1$. For $m<\\frac{n}{2}$, we can apply the above for $(l, k)=(n-m, m)$ yielding\n\n$$\nb_{m}=a_{n+1-m}+a_{m} \\geq a_{n-m}+a_{m+1}=b_{m+1}\n$$\n\nAlso by symmetry $b_{m}=b_{n+1-m}$. Thus\n\n$$\nb_{0}=\\max _{m=0, \\ldots, n+1} b_{m} \\geq \\max _{m=1, \\ldots, n} b_{m} \\geq \\frac{b_{1}+\\cdots+b_{n}}{n}\n$$\n\nsubstituting back yields the desired inequality.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 1.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "2", "problem_type": null, "exam": "BalticWay", "problem": "Does there exist a finite set of real numbers such that their sum equals 2 , the sum of their squares equals 3 , the sum of their cubes equals 4 and the sum of their ninth powers equals 10 ?", "solution": "Answer: no.\n\nAssume that such a set of numbers $\\left\\{a_{1}, \\ldots, a_{n}\\right\\}$ exists. Summing up the inequalities\n\n$$\n2 a_{i}^{3} \\leq a_{i}^{2}+a_{i}^{4}\n$$\n\nfor all $i$ we obtain the inequality $8 \\leq 8$. Therefore all the inequalities are in fact equalities. This is possible for the cases $a_{i}=0$ or $a_{i}=1$ only, but the elements of a set are all different.\n\n(Remark: Even if the $a_{i}$ 's are allowed to be equal it is clear that only 0's or only l's do not satisfy the problem conditions.)", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 2.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "3", "problem_type": null, "exam": "BalticWay", "problem": "Positive integers $x_{1}, \\ldots, x_{m}$ (not necessarily distinct) are written on a blackboard. It is known that each of the numbers $F_{1}, \\ldots, F_{2018}$ can be represented as a sum of one or more of the numbers on the blackboard. What is the smallest possible value of $m$ ?\n\n(Here $F_{1}, \\ldots, F_{2018}$ are the first 2018 Fibonacci numbers: $F_{1}=F_{2}=1, F_{k+1}=F_{k}+F_{k-1}$ for $k>1$.)", "solution": "Answer: the minimal value for $m$ is 1009 .\n\nConstruction: Define $x_{i}=F_{2 i-1}$. This works since $F_{2 k}=F_{1}+F_{3}+\\ldots+F_{2 k-1}$, for all $k$, which can easily be proved by induction. Minimality: Again by induction we get that $F_{k+2}=1+F_{1}+F_{2}+\\ldots+F_{k}$, for all $k$, which means that\n\n$$\nF_{k+2}>F_{1}+F_{2}+\\ldots+F_{k} .\n$$\n\nConsider the numbers that have been used for the representing the first $k$ Fibonacci numbers. Then the sum of these $x_{i}$ 's is less than $F_{k+2}$ due to $(*)$. Thus, at least one additional number is required to deal with $F_{k+2}$. This establishes the lower bound $m \\leq 1009$.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 3.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "4", "problem_type": null, "exam": "BalticWay", "problem": "A linear form in $k$ variables is an expression of the form $P\\left(x_{1}, \\ldots, x_{k}\\right)=a_{1} x_{1}+\\ldots+a_{k} x_{k}$ with real constants $a_{1}, \\ldots, a_{k}$. Prove that there exist a positive integer $n$ and linear forms $P_{1}, \\ldots, P_{n}$ in 2017 variables such that the equation\n\n$$\nx_{1} \\cdot x_{2} \\cdot \\ldots \\cdot x_{2017}=P_{1}\\left(x_{1}, \\ldots, x_{2017}\\right)^{2017}+\\ldots+P_{n}\\left(x_{1}, \\ldots, x_{2017}\\right)^{2017}\n$$\n\nholds for all real numbers $x_{1}, \\ldots, x_{2017}$.", "solution": "For every $\\varepsilon=\\left(\\varepsilon_{1}, \\ldots, \\varepsilon_{n}\\right) \\in\\{ \\pm 1\\}^{2017}$ let\n\n$$\nP_{\\varepsilon}\\left(X_{1}, \\ldots, X_{2017}\\right)=\\varepsilon_{1} X_{1}+\\cdots+\\varepsilon_{2017} X_{2017}\n$$\n\nand $\\beta_{\\varepsilon}=\\varepsilon_{1} \\cdots \\varepsilon_{2017}$. Consider\n\n$$\n\\begin{aligned}\ng\\left(X_{1}, \\ldots, X_{k}\\right) & :=\\sum_{\\varepsilon}\\left(\\beta_{\\varepsilon} P_{\\varepsilon}\\left(X_{1}, \\ldots, X_{2017}\\right)\\right)^{2017} \\\\\n& =\\sum_{\\varepsilon_{1}, \\ldots, \\varepsilon_{2017}} \\varepsilon_{1} \\cdots \\varepsilon_{2017}\\left(\\varepsilon_{1} X_{1}+\\cdots+\\varepsilon_{2017} X_{2017}\\right)^{2017}\n\\end{aligned}\n$$\n\nIf we choose $X_{1}=0$, then every combination $\\left(\\varepsilon_{2} X_{2}+\\cdots+\\varepsilon_{2017} X_{2017}\\right)^{2017}$ occurs exactly twice and with opposite signs in the above sum. Hence, $g\\left(0, X_{2}, \\ldots, X_{2017}\\right) \\equiv 0$. The analogous statements are true for all other variables. Consequently, $g$ is divisible by $X_{1} \\ldots X_{2017}$, and thereby of the form $c X_{1} \\ldots X_{2017}$ for some real constant $c$. If $c \\neq 0$, then both sides can be divided by $c$, and we obtain a representation with $n=2^{2017}$ linear forms.\n\nWith $X_{1}=\\cdots=X_{2017}=1$ we get\n\n$$\n\\begin{aligned}\nc & =\\sum_{\\varepsilon} \\varepsilon_{1} \\cdot \\ldots \\cdot \\varepsilon_{2017}\\left(\\varepsilon_{1}+\\ldots+\\varepsilon_{2017}\\right)^{2017} \\\\\n& =\\sum_{\\varepsilon} \\sum_{\\substack{k_{1}, \\ldots, k_{2017} \\\\\nk_{1}+\\ldots+k_{2017}=2017}}\\left(\\begin{array}{c}\n2017 \\\\\nk_{1}, \\ldots, k_{2017}\n\\end{array}\\right) \\varepsilon_{1}^{k_{1}+1} \\cdot \\ldots \\cdot \\varepsilon_{2017}^{k_{2017}+1}\n\\end{aligned}\n$$\n\nThe part of the sum with $k_{1}$ even is zero since\n\n$$\n\\sum_{\\substack{k_{1} \\text { even,.,.,k } \\\\\nk_{1}+\\ldots+k_{2017}=2017}}\\left(\\begin{array}{c}\n2017 \\\\\nk_{1}, \\ldots, k_{2017}\n\\end{array}\\right)\\left(\\sum_{\\varepsilon, \\varepsilon_{1}=1} \\varepsilon_{2}^{k_{2}+1} \\cdot \\ldots \\cdot \\varepsilon_{2017}^{k_{2017}+1}+\\sum_{\\varepsilon, \\varepsilon_{1}=-1}(-1)^{k_{1}+1} \\cdot \\ldots \\cdot \\varepsilon_{2017}^{k_{2017}+1}\\right)=0\n$$\n\nNow we may consider the part of the sum with $k_{1}$ odd. Similarly the part of this new sum with $k_{2}$ even equals 0 . Doing this for all the variables we get\n\n$$\nc=\\sum_{\\varepsilon=1} \\sum_{\\substack{k_{1} \\text { odd, }, \\ldots, k_{2017} \\text { odd } \\\\\nk_{1}+\\ldots+k_{2017}=2017}}\\left(\\begin{array}{c}\n2017 \\\\\nk_{1}, \\ldots, k_{2017}\n\\end{array}\\right)=2^{2017}\\left(\\begin{array}{c}\n2017 \\\\\n1, \\ldots, 1\n\\end{array}\\right)=2^{2017} \\cdot 2017 ! \\neq 0\n$$\n\nforms.\n\nFinally, we can even merge the two forms with opposite choices of the signs to obtain a representation with $2^{2016}$ linear", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 4.", "solution_match": "\nSolution 1:"}} {"year": "2017", "tier": "T3", "problem_label": "4", "problem_type": null, "exam": "BalticWay", "problem": "A linear form in $k$ variables is an expression of the form $P\\left(x_{1}, \\ldots, x_{k}\\right)=a_{1} x_{1}+\\ldots+a_{k} x_{k}$ with real constants $a_{1}, \\ldots, a_{k}$. Prove that there exist a positive integer $n$ and linear forms $P_{1}, \\ldots, P_{n}$ in 2017 variables such that the equation\n\n$$\nx_{1} \\cdot x_{2} \\cdot \\ldots \\cdot x_{2017}=P_{1}\\left(x_{1}, \\ldots, x_{2017}\\right)^{2017}+\\ldots+P_{n}\\left(x_{1}, \\ldots, x_{2017}\\right)^{2017}\n$$\n\nholds for all real numbers $x_{1}, \\ldots, x_{2017}$.", "solution": "We show by induction that for every integer $k \\geq 1$ there exist an $n=n_{k}$, real numbers $\\lambda_{1}, \\ldots, \\lambda_{n_{k}}$ and linear forms $P_{k, 1}, \\ldots, P_{k, n_{k}}$ in $k$ variables such that\n\n$$\nx_{1} \\ldots x_{k}=\\lambda_{1} P_{k, 1}\\left(x_{1}, \\ldots, x_{k}\\right)^{k}+\\cdots+\\lambda_{n_{k}} P_{k, n_{k}}\\left(x_{1}, \\ldots, x_{k}\\right)^{k} .\n$$\n\nFor $k=1$ we can choose $n=n_{1}=1$ and $P_{1,1}\\left(x_{1}\\right)=x_{1}$. Now for the induction step, we observe that\n\n$$\nx_{1} \\ldots x_{k} y=\\lambda_{1} P_{k, 1}\\left(x_{1}, \\ldots, x_{k}\\right)^{k} y+\\cdots+\\lambda_{k} P_{k, n_{k}}\\left(x_{1}, \\ldots, x_{k}\\right)^{k} y\n$$\n\nThus it suffices to write $X^{k} Y$ as a linear combination of $(k+1)$-th powers of linear forms in $X$ and $Y$. The set-up\n\n$$\nX^{k} Y=\\sum_{i=1}^{m} \\alpha_{i}\\left(X+\\beta_{i} Y\\right)^{k+1}\n$$\n\nleads to the equations $\\sum_{i} \\alpha_{i} \\beta_{i}=\\frac{1}{k+1}$ and $\\sum_{i} \\alpha_{i} \\beta_{i}^{d}=0$ for $d=0,2,3, \\ldots, k+1$. Choosing $m=k+2$ and distinct values for the $\\beta_{i}$ 's, this becomes a system of $k+2$ linear equations in the $k+2$ variables $\\alpha_{i}$. If the system had no solution, then the lefthand sides of the equations would be linearly dependent. On the other hand, given $c_{j}, j=0,1, \\ldots, k+1$ with $\\sum_{j} c_{j} \\beta_{i}^{j}=0$ for all $i$, the polynomial $P(x)=\\sum_{j} c_{j} x^{j}$ has degree at most $k+1$ and the $k+2$ distinct zeros $b_{1}, \\ldots, b_{k+2}$ and, hence, is the zero polynomial. Consequently, the system has a solution, and we can choose $n_{k+1}=(k+2) n_{k}$ and the induction is complete.\n\nThe above gives us\n\n$$\n\\begin{aligned}\nx_{1} \\ldots x_{2017} & =\\lambda_{1} P_{2017,1}\\left(x_{1}, \\ldots, x_{2017}\\right)^{2017}+\\cdots+\\lambda_{n_{2017}} P_{2017, n_{2017}}\\left(x_{1}, \\ldots, x_{2017}\\right)^{2017} \\\\\n& =\\left(\\lambda_{1}^{1 / 2017} P_{2017,1}\\left(x_{1}, \\ldots, x_{2017}\\right)\\right)^{2017}+\\cdots+\\left(\\lambda_{n_{2017}}^{1 / 2017} P_{2017, n_{2017}}\\left(x_{1}, \\ldots, x_{2017}\\right)\\right)^{2017},\n\\end{aligned}\n$$\n\nas wanted.\n\nRemark: Of course, the consistency of the system of linear equations also follows by the fact that the determinant of the coefficient matrix does not vanish as it is of Vandermonde's type.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 4.", "solution_match": "\nSolution 2:"}} {"year": "2017", "tier": "T3", "problem_label": "5", "problem_type": null, "exam": "BalticWay", "problem": "Find all functions $f: \\mathbb{R} \\rightarrow \\mathbb{R}$ such that\n\n$$\nf\\left(x^{2} y\\right)=f(x y)+y f(f(x)+y)\n$$\n\nfor all real numbers $x$ and $y$.", "solution": "Answer: $f(y)=0$.\n\nBy substituting $x=0$ into the original equation we obtain $f(0)=f(0)+y f(f(0)+y)$, which after simplifying yields $y f(f(0)+$ $y)=0$. This has to hold for every $y$.\n\nNow let's substitute $y=-f(0)$. We get that $-(f(0))^{2}=0$, which gives us $f(0)=0$.\n\nBy plugging the last result into $y f(f(0)+y)=0$ we now get that $y f(y)=0$.\n\nTherefore if $y \\neq 0$ then $f(y)=0$.\n\nAltogether we have shown that $f(y)=0$ for every $y$ is the only possible solution, and it clearly is a solution.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 5.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "6", "problem_type": null, "exam": "BalticWay", "problem": "Fifteen stones are placed on a $4 \\times 4$ board, one in each cell, the remaining cell being empty. Whenever two stones are on neighbouring cells (having a common side), one may jump over the other to the opposite neighbouring cell, provided this cell is empty. The stone jumped over is removed from the board.\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-03.jpg?height=63&width=405&top_left_y=1385&top_left_x=834)\n\nFor which initial positions of the empty cell is it possible to end up with exactly one stone on the board?", "solution": "There are three types of cells on the board: corner cells, edge cells and centre cells. Colour the cells in three distinct colours as follows.\n\n$$\n\\begin{array}{|c|c|c|c|}\n\\hline \\mathrm{A} & \\mathrm{B} & \\mathrm{C} & \\mathrm{A} \\\\\n\\hline \\mathrm{B} & \\mathrm{C} & \\mathrm{A} & \\mathrm{B} \\\\\n\\hline \\mathrm{C} & \\mathrm{A} & \\mathrm{B} & \\mathrm{C} \\\\\n\\hline \\mathrm{A} & \\mathrm{B} & \\mathrm{C} & \\mathrm{A} \\\\\n\\hline\n\\end{array}\n$$\n\nSuppose there are initially $a, b, c$ stones on cells of colours A, B, C, respectively. With each move, one of these numbers will increase by 1 , while the other two will decrease by 1 . Because there are fourteen moves altogether, the game must end with $a, b, c$ of the same parity as they originally had. There are $6,5,5$ cells of each colour on the board, so if the game should end with a single stone remaining, the game must begin with\n\n$$\na=6, b=5, c=4 \\quad \\text { or } \\quad a=6, b=4, c=5 \\text {. }\n$$\n\nThe empty slot should thus have colour B or C. This excludes the corner cells and two of the centre cells. However, by symmetry (changing the colouring), the two remaining centre cells will also be excluded. Hence the empty space at the beginning must be at an edge cell. That the game is indeed winnable in this case can be seen from the sequence of moves here:\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-03.jpg?height=383&width=1117&top_left_y=2370&top_left_x=478)", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 6.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "7", "problem_type": null, "exam": "BalticWay", "problem": "Each edge of a complete graph on 30 vertices is coloured either red or blue. It is allowed to choose a nonmonochromatic triangle and change the colour of the two edges of the same colour to make the triangle monochromatic. Prove that by using this operation repeatedly it is possible to make the entire graph monochromatic.\n\n(A complete graph is a graph where any two vertices are connected by an edge.)", "solution": "The total number of edges is odd. Assume without loss of generality that the number of blue edges is odd, and the number of red edges is even. It is clear that the parity of the number of edges of each colour does not change by the operations.\n\nConsider a graph with maximal number of blue edges that can be obtained by these operations. Suppose that not all of its edges are blue. Then it contains at least two red edges. Because of maximality, it is not possible to have a triangle with exactæy two red edges.\n\nCase 1. It contains two red edges $A B$ and $B C$ sharing a common vertex. Then edge $A C$ is coloured in red, too. If there exists a vertex $D$ such that the edges $D A, D B, D C$ are not of the same colour, then wlog we can assume that $D A$ is red and $D B$ is blue, but then we have a triangle $A B D$ with exactly two red edges, a contradiction.\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-04.jpg?height=300&width=303&top_left_y=889&top_left_x=885)\n\nIf some vertex $D$ is connected to $A, B$ and $C$ with blue edges, then perform the operation on the triangles $B C D, A B D$, $A C D$, and the number of blue edges increases, a contradiction.\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-04.jpg?height=300&width=1626&top_left_y=1339&top_left_x=220)\n\nOtherwise all the vertices are connected to $A, B$ and $C$ with red edges. Due to parity we have at least one blue edge. If $X$ and $Y$ are connected by a blue edge, then perform the operation on $A X Y$, and the number of blue edges increases, a contradiction.\n\nCase 2. Every two red edges have no common vertex. Let $A B$ and $C D$ be red edges. Perform the operation in the triangles $A B D, B C D, A B D$. The number of blue edges increases.\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-04.jpg?height=298&width=1626&top_left_y=1915&top_left_x=220)", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 7.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "8", "problem_type": null, "exam": "BalticWay", "problem": "A chess knight has injured his leg and is limping. He alternates between a normal move and a short move where he moves to any diagonally neighbouring cell.\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-05.jpg?height=315&width=317&top_left_y=385&top_left_x=732)\n\nNormal move\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-05.jpg?height=199&width=195&top_left_y=503&top_left_x=1136)\n\nShort move\n\nThe limping knight moves on a $5 \\times 6$ cell chessboard starting with a normal move. What is the largest number of moves he can make if he is starting from a cell of his own choice and is not allowed to visit any cell (including the initial cell) more than once?", "solution": "Answer: 25 moves.\n\nLet us enumerate the rows of the chessboard with numbers 1 to 5 . We will consider only the short moves. Each short move connects two cells from rows of different parity and no two short moves has a common cell. Therefore there can be at most 12 short moves as there are just 12 cells in the rows of even parity (second and fourth). It means that the maximal number of moves is 12 short +13 normal $=25$ moves.\n\nThe figure shows that 25 moves indeed can be made.\n\n| 19 | 5 | 7 | 9 | 11 | |\n| :---: | :---: | :---: | :---: | :---: | :---: |\n| 4 | 18 | 20 | 6 | 8 | 10 |\n| | 2 | | 21 | 26 | 12 |\n| 17 | 3 | 24 | 15 | 13 | 22 |\n| 2 | 16 | 14 | 25 | 23 | |", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 8.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "9", "problem_type": null, "exam": "BalticWay", "problem": "A positive integer $n$ is Danish if a regular hexagon can be partitioned into $n$ congruent polygons. Prove that there are infinitely many positive integers $n$ such that both $n$ and $2^{n}+n$ are Danish.", "solution": "At first we note that $n=3 k$ is danish for any positive integer $k$, because a hexagon can be cut in 3 equal parallelograms each of which can afterwards be cut in $k$ equal parallelograms (Fig 1).\n\nFurthermore a hexagon can be cut into two equal trapezoids (Fig. 2) each of which can afterwards be cut into 4 equal trapezoids of the same shape (Fig. 3) and so on. Therefore any number of the form $n=2 \\cdot 4^{k}$ is also danish.\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-05.jpg?height=180&width=206&top_left_y=1966&top_left_x=662)\n\nFigure 1\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-05.jpg?height=174&width=188&top_left_y=1969&top_left_x=937)\n\nFigure 2\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-05.jpg?height=174&width=192&top_left_y=1969&top_left_x=1206)\n\nFigure 3\n\nIf we take any danish number $n=2 \\cdot 4^{k}$ of the second type, then\n\n$$\n2^{n}+n=2^{2 \\cdot 4^{k}}+2 \\cdot 4^{k} \\equiv 1+2 \\equiv 0(\\bmod 3)\n$$\n\nshowing that $2^{n}+n$ is also a danish number.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 9.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "10", "problem_type": null, "exam": "BalticWay", "problem": "Maker and Breaker are building a wall. Maker has a supply of green cubical building blocks, and Breaker has a supply of red ones, all of the same size. On the ground, a row of $m$ squares has been marked in chalk as place-holders. Maker and Breaker now take turns in placing a block either directly on one of these squares, or on top of another block already in place, in such a way that the height of each column never exceeds $n$. Maker places the first block.\n\nMaker bets that he can form a green row, i.e. all $m$ blocks at a certain height are green. Breaker bets that he can prevent Maker from achieving this. Determine all pairs $(m, n)$ of positive integers for which Maker can make sure he wins the bet.", "solution": "Answer: Maker has a winning strategy if $m>1$ and $n>1$ are both odd, or if $m=1$.\n\nLet us refer to the positions of the blocks in the wall by coordinates $(x, y)$ where $x \\in\\{0,1, \\ldots, m-1\\}$ refers to the column and $y \\in\\{0,1, \\ldots, n-1\\}$ to the height of the block. Consider the different cases according to the parity of the parameters. In addition, there are some exceptional trivial cases.\n\n1) If $m=1$, then Maker trivially wins by the first move.\n2) If $m>1$, but $n=1$, then Breaker obviously can break the only row.\n3) Suppose $m$ is even. Then Breaker has a defensive strategy based on the horizontal reflection, i.e. if Maker places a block in $(x, y)$, then Breaker places a block in $(m-1-x, y)$. Note that this move is always available for Breaker, because $m$ is even. It is clear that this reflection strategy breaks all the green rows.\n4) Suppose then $n$ is even but $m>1$ is odd. Then Breaker has the same defensive stra-tegy as above based on the horizontal reflection, with one modification: Whenever Maker places a block in the middle column, Breaker does too. Since $n$ is even, this middle column does not influence the rest of the construction. Hence this reflection strategy breaks all the green rows as above.\n5) Suppose both $m$ and $n$ are odd, $m>1$ and $n>1$. Maker's strategy is the following: Maker starts with $(0,0)$. Maker pairs the positions $(2 i-1,0)$ and $(2 i, 0), i=1,2, \\ldots, \\frac{m-1}{2}$, so that if Breaker places a red block in one of the positions, Maker places a green block in the other position; otherwise Maker does not use the bottom row. Maker's reply to Breaker's $(x, y)$ with $y>0$ is $(x, y+1)$. This strategy builds a green row at the height 2 .", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 10.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "11", "problem_type": null, "exam": "BalticWay", "problem": "Let $H$ and $I$ be the orthocentre and incentre, respectively, of an acute angled triangle $A B C$. The circumcircle of the triangle $B C I$ intersects the segment $A B$ at the point $P$ different from $B$. Let $K$ be the projection of $H$ onto $A I$ and $Q$ the reflection of $P$ in $K$. Show that $B, H$ and $Q$ are collinear.", "solution": "Let $H^{\\prime}$ be the reflection of $H$ in $K$. The reflection about the point $K$ sends $Q$ to $P$, and the line $B H$ to the line through $H^{\\prime}$ and orthogonal to $A C$. The reflection about the line $A I$ sends $P$ to $C$, and the line through $H^{\\prime}$ orthogonal to $A C$ to the line through $H$ orthogonal to $A B$, but this is just $B H$. Since composition of the two reflections sends $B, H$ and $Q$ to the same line, it follows that $B, H$ and $Q$ are collinear.\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-06.jpg?height=537&width=768&top_left_y=1556&top_left_x=655)", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 11.", "solution_match": "\nSolution 1:"}} {"year": "2017", "tier": "T3", "problem_label": "11", "problem_type": null, "exam": "BalticWay", "problem": "Let $H$ and $I$ be the orthocentre and incentre, respectively, of an acute angled triangle $A B C$. The circumcircle of the triangle $B C I$ intersects the segment $A B$ at the point $P$ different from $B$. Let $K$ be the projection of $H$ onto $A I$ and $Q$ the reflection of $P$ in $K$. Show that $B, H$ and $Q$ are collinear.", "solution": "Let $\\alpha=\\frac{1}{2} \\angle B A C, \\beta=\\frac{1}{2} \\angle C B A$, and $\\gamma=\\frac{1}{2} \\angle A C B$. Clearly then $\\alpha+\\beta+\\gamma=90^{\\circ}$, which yields $\\angle B I C=180^{\\circ}-\\beta-\\gamma=$ $90^{\\circ}+\\alpha$. From this we get $\\angle C P A=180^{\\circ}-\\angle B P C=180^{\\circ}-\\angle B I C=90^{\\circ}-\\alpha$, so triangle $A P C$ is isosceles.\n\nNow since $A I$ is the anglebisector of $\\angle P A C$ it must also be the perpendicular bisector of $C P$. Hence $C K=P K=Q K$ so triangle $K C Q$ is isosceles. Additionally $A I$ bisects $P Q$ so $A I$ is the midline of triangle $P C Q$ parallel to $C Q$. Since $K H$ is perpendicular to $A I$, it is also perpendicular to $C Q$, so we may then conclude by symmetry that $H C Q$ is also isosceles. Moreover $\\angle Q C A=\\angle I A C=\\alpha$, and $\\angle A C H=90^{\\circ}-2 \\alpha$, so $\\angle Q C H=\\alpha+90^{\\circ}-2 \\alpha=90^{\\circ}-\\alpha$, which means that triangles $H C Q$ and $A P C$ are similar. In particular we have $\\angle C H Q=2 \\alpha$. Since also\n\n$$\n180^{\\circ}-\\angle B H C=\\angle H C B+\\angle C B H=90^{\\circ}-2 \\beta+90^{\\circ}-2 \\gamma=2 \\alpha\n$$\n\nit follows that $B, H$, and $Q$ are collinear.\n\nTo prove that $Q$ always lies outside of triangle $A B C$ one could do the following: Since $P$ lies on $A B$, angle $C$ is larger than angle $B$ in triangle $A B C$. Thus angle $A D B$ is obtuse, where $D$ is the intersection point between $A I$ and $B C$. As $Q C$ and $A I$ are parallel, angle $Q C B$ is obtuse. Thus $Q$ lies outside of triangle $A B C$.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 11.", "solution_match": "\nSolution 2:"}} {"year": "2017", "tier": "T3", "problem_label": "12", "problem_type": null, "exam": "BalticWay", "problem": "Line $\\ell$ touches circle $S_{1}$ in the point $X$ and circle $S_{2}$ in the point $Y$. We draw a line $m$ which is parallel to $\\ell$ and intersects $S_{1}$ in a point $P$ and $S_{2}$ in a point $Q$. Prove that the ratio $X P / Y Q$ does not depend on the choice of $m$.", "solution": "Let $T$ be the second intersection point of $P Q$ and $S_{1}$ and $R$ be the second intersection point of $P Q$ and $S_{2}$. Let $\\angle P X T=\\alpha$, $\\angle R Y Q=\\beta$. It is evident that $P X=X T, R Y=Y Q$. Calculate the ratio area ${ }_{P X T} /$ area $_{R Y Q}$ by two different ways. First,\n\n$$\n\\frac{\\operatorname{area}_{P X T}}{\\operatorname{area}_{R Y Q}}=\\frac{X P^{2} \\sin \\alpha}{Y Q^{2} \\sin \\beta}\n$$\n\nSecond,\n\nEquating these expressions we obtain\n\n$$\n\\frac{\\operatorname{area}_{P X T}}{\\operatorname{area}_{R Y Q}}=\\frac{P T}{R Q}=\\frac{2 R_{1} \\sin \\alpha}{2 R_{2} \\sin \\beta}\n$$\n\n$$\n\\frac{X P}{Y Q}=\\sqrt{\\frac{R_{1}}{R_{2}}}\n$$", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 12.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "13", "problem_type": null, "exam": "BalticWay", "problem": "Let $A B C$ be a triangle in which $\\angle A B C=60^{\\circ}$. Let $I$ and $O$ be the incentre and circumcentre of $A B C$, respectively. Let $M$ be the midpoint of the arc $B C$ of the circumcircle of $A B C$, which does not contain the point $A$. Determine $\\angle B A C$ given that $M B=O I$.", "solution": "Since $\\angle A B C=60^{\\circ}$, we have $\\angle A I C=\\angle A O C=120^{\\circ}$. Let $I^{\\prime}, O^{\\prime}$ be the points symmetric to $I, O$ with respect to $A C$, respectively. Then $I^{\\prime}$ and $O^{\\prime}$ lie on the circumcircle of $A B C$. Since $O^{\\prime} I^{\\prime}=O I=M B$, the angles determined by arcs $O^{\\prime} I^{\\prime}$ and $M B$ are equal. It follows that $\\angle M A B=\\angle I^{\\prime} A O^{\\prime}$.\n\nNow, denoting $\\angle B A C=\\alpha$, we have\n\n$$\n\\angle I^{\\prime} A O^{\\prime}=\\angle I A O=|\\angle I A C-\\angle O A C|=\\left|\\frac{\\alpha}{2}-30^{\\circ}\\right|\n$$\n\nIt follows that $\\frac{\\alpha}{2}=\\angle M A B=\\angle I^{\\prime} A O^{\\prime}=\\left|\\frac{\\alpha}{2}-30^{\\circ}\\right|$, i.e. $\\alpha=30^{\\circ}$.\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-07.jpg?height=554&width=560&top_left_y=1590&top_left_x=745)", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 13.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "14", "problem_type": null, "exam": "BalticWay", "problem": "Let $P$ be a point inside the acute angle $\\angle B A C$. Suppose that $\\angle A B P=\\angle A C P=90^{\\circ}$. The points $D$ and $E$ are on the segments $B A$ and $C A$, respectively, such that $B D=B P$ and $C P=C E$. The points $F$ and $G$ are on the segments $A C$ and $A B$, respectively, such that $D F$ is perpendicular to $A B$ and $E G$ is perpendicular to $A C$. Show that $P F=P G$.", "solution": "As $\\triangle P B D$ is an isosceles right triangle $\\angle G D P=\\angle B D P=45^{\\circ}$. Similarly $\\angle P E C=45^{\\circ}$, and thus $\\angle P E G=45^{\\circ}$. Therefore $P G D E$ is cyclic. As $\\angle G D F$ and $\\angle G E F$ are right $E F G D$ is cyclic. Therefore $D G P F E$ is a cyclic pentagon. Therefore $\\angle G F P=\\angle G E P=45^{\\circ}$. Similarly $\\angle F G P=45^{\\circ}$. Therefore $\\triangle F P G$ is a (right) isosceles triangle.\n\n![](https://cdn.mathpix.com/cropped/2024_04_17_6a5543a8a260575a56cdg-08.jpg?height=477&width=623&top_left_y=258&top_left_x=725)\n\nRemark: It can be shown given two intersecting lines $l$ and $m$, not perpendicular to one another and an point $P$. there exist unique points $F$ and $G$ on $l$ and $m$ respectively such that $\\triangle F P G$ is an right isosceles triangle using similar constructions to above.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 14.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "15", "problem_type": null, "exam": "BalticWay", "problem": "Let $n \\geq 3$ be an integer. What is the largest possible number of interior angles greater than $180^{\\circ}$ in an $n$-gon in the plane, given that the $n$-gon does not intersect itself and all its sides have the same length?", "solution": "Answer: 0 if $n=3,4$ and $n-3$ for $n \\geq 5$.\n\nIf $n=3,4$ then any such $n$-gon is a triangle, resp. a rhombus, therefore the answer is 0 .\n\nIf $n=5$ then consider a triangle with side lengths 2,2,1. Now move the vertex between sides of length 2 towards the opposite side by 0.0000001 units. Consider the triangle as a closed physical chain of links of length 1 that are aluminium tubes and through them is a closed rubber string. So deform the chain on a level surface so that links of the chain move towards the inside of the triangle, by fixing the vertices of the triangle to the surface. Geometrically, the links which are on sides of length 2 are now distinct chords of a large circle, attached to each other by their endpoints.\n\nIf $n>5$ then first consider a triangle of integer sides lengths, with sides of as equal lengths as possible, so that the sum of side lengths is $n$. Imagine a closed aluminium chain on a rubber string, as in the previous case. Now move two of the vertices of the triangle towards the third one be 0.00000001 units each. Again consider the chain on a level surface and deform it so that its links move towards the interior of the triangle. Geometrically each side of a triangle is deformed into consecutive equal-length chords of a large circle with centre far away from the original triangle.\n\nFor $n \\geq 5$ this gives an example of $n-3$ interior angles of more than $180^{\\circ}$.\n\nTo see that $n-2$ or more such angles is not possible, note than the sum of interior angles of any $n$-gon (that does not cut itself) is equal to $(n-2) 180^{\\circ}$, but already the sum of the 'large' angles would be greater than that if there were at least $n-2$ of 'large' angles of size greater than $180^{\\circ}$.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 15.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "16", "problem_type": null, "exam": "BalticWay", "problem": "Is it possible for any group of people to choose a positive integer $N$ and assign a positive integer to each person in the group such that the product of two persons' numbers is divisible by $N$ if and only if they are friends?", "solution": "Answer: Yes, this is always possible.\n\nConsider a graph with a vertex for each person in the group. For each pair of friends we join the corresponding vertices by a red edge. If a pair are not friends, we join their vertices with a blue edge.\n\nLet us label blue edges with different primes $p_{1}, \\ldots, p_{k}$. To a vertex $A$ we assign the number $n(A)=\\frac{P^{2}}{P(A)}$, where $P=$ $p_{1} p_{2} \\ldots p_{k}$, and $P(A)$ is the product of the primes on all blue edges starting from $A$ (for the empty set the product of all its elements equals 1). Now take $N=P^{3}$.\n\nLet us check that all conditions are satisfied. If vertices $A$ and $B$ are connected by a red edge, then $P(A)$ and $P(B)$ are coprime, hence $P(A) P(B) \\mid P$ and $P^{3} \\left\\lvert\\, n(A) n(B)=\\frac{P^{4}}{P(A) P(B)}\\right.$. If vertices $A$ and $B$ are connected by a blue edge labelled with a prime $q$, then $q^{2}$ divides neither $n(A)$ nor $n(B)$. Hence $q^{3}$ does not divide $n(A) n(B)$.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 16.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "17", "problem_type": null, "exam": "BalticWay", "problem": "Determine whether the equation\n\n$$\nx^{4}+y^{3}=z !+7\n$$\n\nhas an infinite number of solutions in positive integers.", "solution": "We consider the equation modulo 13 since both 3 and 4 divides $12=13-1$. Now $x^{4} \\bmod 13 \\in\\{0,1,3,9\\}$ and $y^{3} \\bmod 13 \\in$ $\\{0,1,5,8,12\\}$. We can verify that $x^{4}+y^{3} \\not \\equiv 7 \\bmod 13$. However $z !+7 \\equiv 7 \\bmod 13$ if $z \\geq 13$, what leads to a conclusion that this equation has no solutions with $z \\geq 13$, what proves that it has finite number of solutions.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 17.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "18", "problem_type": null, "exam": "BalticWay", "problem": "Let $p>3$ be a prime and let $a_{1}, a_{2}, \\ldots, a_{\\frac{p-1}{2}}$ be a permutation of $1,2, \\ldots, \\frac{p-1}{2}$. For which $p$ is it always possible to determine the sequence $a_{1}, a_{2}, \\ldots, a_{\\frac{p-1}{2}}$ if for all $i, j \\in\\left\\{1,2, \\ldots, \\frac{p-1}{2}\\right\\}$ with $i \\neq j$ the residue of $a_{i} a_{j}$ modulo $p$ is known?", "solution": "Answer: For all primes $p>5$.\n\nWhen $p=5$ it is clear that it is not possible to determine $a_{1}$ and $a_{2}$ from the residue of $a_{1} a_{2}$ modulo 5 .\n\nAssume that $p>5$. Now $\\frac{p-1}{2} \\geq 3$. For all $i \\in\\left\\{1,2, \\ldots, \\frac{p-1}{2}\\right\\}$ it is possible to choose $j, k \\in\\left\\{1,2, \\ldots, \\frac{p-1}{2}\\right\\}$ such that $i, j$ and $k$ are different. Thus we know\n\n$$\na_{i}^{2} \\equiv\\left(a_{i} a_{j}\\right)\\left(a_{i} a_{k}\\right)\\left(a_{j} a_{k}\\right)^{-1}(\\bmod p) .\n$$\n\nThe equation $x^{2} \\equiv a(\\bmod p)$ has exactly one solution in $\\left\\{1,2, \\ldots, \\frac{p-1}{2}\\right\\}$, and hence it is possible to determine $a_{i}$ for all $i$.", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 18.", "solution_match": "# Solution\n"}} {"year": "2017", "tier": "T3", "problem_label": "19", "problem_type": null, "exam": "BalticWay", "problem": "For an integer $n \\geq 1$ let $a(n)$ denote the total number of carries which arise when adding 2017 and $n \\cdot 2017$. The first few values are given by $a(1)=1, a(2)=1, a(3)=0$, which can be seen from the following:\n\n| 001 | 001 | 000 |\n| :---: | :---: | :---: |\n| 2017 | 4034 | 6051 |\n| +2017 | +2017 | +2017 |\n| $=4034$ | $=6051$ | $=8068$ |\n\nProve that\n\n$$\na(1)+a(2)+\\ldots+a\\left(10^{2017}-2\\right)+a\\left(10^{2017}-1\\right)=10 \\cdot \\frac{10^{2017}-1}{9}\n$$", "solution": "Let $k(m)$ be the residue of $m$ when divided by $10^{k}$. There is a carry at the digit representing $10^{k}$ exactly when $k(2017)+k(n \\cdot 2017)>10^{k}$. Thus the number of 10-, 100-, 1000- and 10000-carries are, respectively,\n\n$$\n\\left\\lfloor\\frac{7 \\cdot 10^{2017}}{10}\\right\\rfloor,\\left\\lfloor\\frac{17 \\cdot 10^{2017}}{100}\\right\\rfloor,\\left\\lfloor\\frac{17 \\cdot 10^{2017}}{1000}\\right\\rfloor,\\left\\lfloor\\frac{2017 \\cdot 10^{2017}}{10000}\\right\\rfloor\n$$\n\nand similarly for the rest of the carries. Thus\n\n$$\n\\begin{aligned}\n\\sum_{n=1}^{10^{2017}-1} a(n) & =7 \\cdot 10^{2016}+17 \\cdot 10^{2015}+\\ldots+2017+201+20+2 \\\\\n& =(2+0+1+7) \\cdot 10^{2016}+(2+0+1+7) \\cdot 10^{2015}+\\ldots+(2+0+1+7)=10 \\cdot \\frac{10^{2017}-1}{9}\n\\end{aligned}\n$$", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 19.", "solution_match": "\nSolution 1:"}} {"year": "2017", "tier": "T3", "problem_label": "19", "problem_type": null, "exam": "BalticWay", "problem": "For an integer $n \\geq 1$ let $a(n)$ denote the total number of carries which arise when adding 2017 and $n \\cdot 2017$. The first few values are given by $a(1)=1, a(2)=1, a(3)=0$, which can be seen from the following:\n\n| 001 | 001 | 000 |\n| :---: | :---: | :---: |\n| 2017 | 4034 | 6051 |\n| +2017 | +2017 | +2017 |\n| $=4034$ | $=6051$ | $=8068$ |\n\nProve that\n\n$$\na(1)+a(2)+\\ldots+a\\left(10^{2017}-2\\right)+a\\left(10^{2017}-1\\right)=10 \\cdot \\frac{10^{2017}-1}{9}\n$$", "solution": "Let $s(n)$ denote the digit sum of $n$. Then we claim the following.\n\nLemma. We have\n\n$$\ns(n+m)=s(n)+s(m)-9 a(n, m)\n$$\n\nwhere $a(n, m)$ denotes the total number of carries, which arises when adding $n$ and $m$.\n\nProof: We proceed by induction on the maximal number of digits $k$ of $n$ and $m$.\n\nIf both $n$ and $m$ are single digit numbers then we have just two cases. If $n+m<10$, then we have no carries and clearly $s(n+m)=n+m=s(n)+s(m)$. If on the other hand $n+m=10+k \\geq 10$, then\n\n$$\ns(n+m)=1+k=1+(n+m-10)=s(n)+s(m)-9\n$$\n\nAssume that the claim holds for all pair with at most $k$ digits each. Let $n=n_{1}+a \\cdot 10^{k+1}$ and $m=m_{1}+b \\cdot 10^{k+1}$ where $n_{1}$ og $m_{1}$ are at most $k$ digit numbers. If there is no carry at the $k+1$ th digit, then $a(n, m)=a\\left(n_{1}, m_{1}\\right)$ and thus\n\n$$\n\\begin{gathered}\ns(n+m)=s\\left(n_{1}+m_{1}\\right)+a+b \\\\\n=s\\left(n_{1}\\right)+a+s\\left(m_{1}\\right)+b-9 a\\left(n_{1}, m_{1}\\right)=s(n)+s(m)-9 a(n, m)\n\\end{gathered}\n$$\n\nIf there is a carry then $a(n, m)=1+a\\left(n_{1}, m_{1}\\right)$ and thus\n\n$$\ns(n+m)=s\\left(n_{1}+m_{1}\\right)+a+b-9\n$$\n\n$$\n=s\\left(n_{1}\\right)+a+s\\left(m_{1}\\right)+b-9\\left(a\\left(n_{1}, m_{1}\\right)+1\\right)=s(n)+s(m)-9 a(n, m)\n$$\n\nThis finishes the induction and we are done.\n\nNow observe that $s\\left(2017 \\cdot 10^{2017}\\right)=2+1+7=10$. We now use (1) a total of $10^{2017}-1$ times which yields\n\n$$\n\\begin{aligned}\n10 & =s\\left(2017 \\cdot 10^{2017}\\right)=s\\left(2017 \\cdot\\left(10^{2017}-1\\right)+2017\\right) \\\\\n& =s\\left(2017 \\cdot\\left(10^{2017}-1\\right)\\right)+s(2017)-9 \\cdot a\\left(10^{2017}-1\\right) \\\\\n& \\vdots \\\\\n& =s(2017)+s(2017) \\cdot\\left(10^{2017}-1\\right)-9 \\cdot \\sum_{n=1}^{10^{2017}-1} a(n) \\\\\n& =10 \\cdot 10^{2017}-9 \\cdot \\sum_{n=1}^{10^{2017}-1} a(n)\n\\end{aligned}\n$$\n\nThus we arrive at\n\n$$\n\\sum_{n=1}^{10^{2017}-1} a(n)=10 \\cdot \\frac{10^{2017}-1}{9}\n$$", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 19.", "solution_match": "\nSolution 2:"}} {"year": "2017", "tier": "T3", "problem_label": "20", "problem_type": null, "exam": "BalticWay", "problem": "Let $S$ be the set of all ordered pairs $(a, b)$ of integers with $0<2 a<2 b<2017$ such that $a^{2}+b^{2}$ is a multiple of 2017. Prove that\n\n$$\n\\sum_{(a, b) \\in S} a=\\frac{1}{2} \\sum_{(a, b) \\in S} b\n$$", "solution": "Let $A=\\{a:(a, b) \\in S\\}$ and $B=\\{b:(a, b) \\in S\\}$. The claim is equivalent to\n\n$$\n2 \\sum_{a \\in A} a=\\sum_{b \\in B} b\n$$\n\nAssume that for some $x, y, z \\in\\{1,2, \\ldots, 1008\\}$ both, $x^{2}+y^{2}$ and $x^{2}+z^{2}$, are multiples of 2017. By\n\n$$\n\\left(x^{2}+y^{2}\\right)-\\left(x^{2}+z^{2}\\right)=y^{2}-z^{2}=(y+z)(y-z) \\equiv 0(\\bmod 2017),\n$$\n\n$01008$, then $g(a)=f(a)-a<(f(a)-a)+(2017-2 f(a))=$ $2017-(a+f(a))=h(a)$. Consequently, $g(a) \\in A$ with $f(g(a))=h(a)$.\n\nIt remains to show that $g$ is injective. Assume that $g\\left(a_{1}\\right)=g\\left(a_{2}\\right)$ for some $a_{1}, a_{2} \\in A$, i.e.,\n\n$$\nb_{1}-a_{1}=b_{2}-a_{2},\n$$\n\nwhere $b_{i}=f\\left(a_{i}\\right)$ for $i=1,2$. Clearly, we also have $h\\left(a_{1}\\right)=h\\left(a_{2}\\right)$ then. If $h\\left(a_{1}\\right)=a_{1}+b_{1}$ and $h\\left(a_{2}\\right)=a_{2}+b_{2}$, then subtracting (3) from $a_{1}+b_{1}=a_{2}+b_{2}$ gives $a_{1}=a_{2}$. Similarly, if $h_{1}\\left(a_{1}\\right)=2017-\\left(a_{1}+b_{1}\\right)$ and $h_{2}=2017-\\left(a_{2}+b_{2}\\right)$, then we obtain $a_{1}=a_{2}$. Finally, if $h\\left(a_{1}\\right)=a_{1}+b_{1}$ and $h_{2}=2017-\\left(a_{2}+b_{2}\\right)$, then $2\\left(a_{1}+b_{2}\\right)=2017$, a contradiction.\n\nRemark: The proof as given above obviously works for any prime congruent to 1 modulo 4 in the place of 2017. With a little more effort, one can show that the statement is true for any positive odd $n$ (vacuously, if $n$ has a prime factor congruent to 3 modulo 4).", "metadata": {"resource_path": "BalticWay/segmented/en-bw17sol.jsonl", "problem_match": "\nProblem 20.", "solution_match": "# Solution\n"}}