$49$ integers are ordered around a circle. It is given that for any two adjacent numbers $x,y$ we have $x+y=(x-y)^2$. Find the maximal sum of all numbers in the circle.
Solution
Note that $x+y=(x-y)^2$ may be written as $(2x-2y+1)^2=8y+1$ or also $(2y-2x+1)^2=8x+1$ And so all elements are such that $8x+1\ge 0$
Replacing all elements $x$ on the circle by $X=\sqrt{8x+1}$ the relation becomes $X=\pm Y\pm 2$ (always with the constraint $X,Y\ge 0$)
So, applying $n$ times this process starting from $a$, we get $\pm a+(\overbrace{\pm 1\pm 1 ... \pm 1}^{n\text{ times}})2$
In order to have a cycle after $49$ steps, we get $a=\pm a+(\overbrace{\pm 1\pm 1 ... \pm 1}^{49\text{ times}})2$ The second part is twice an odd number and so can never be zero and so we need the $\pm a$ in RHS be $-a$ And so $a=(\overbrace{\pm 1\pm 1 ... \pm 1}^{49\text{ times}})\le 49$
Note that in order the $\pm a$ becomes $-a$, at least one transformation needs to be $X\to 2-X$ and so $X=1$
It is easy to see that the optimum sequence for Xs then will be : $(49,47,45,...,3,1,1,3,5,...,45,47),(49,47,45,...,3,1,1,3,5,...,45,47),...$
Which is, for the original sequence of $49$ numbers : $\frac{49^2-1}8,\frac{47^2-1}8,...,\frac{3^2-1}8,0,0,\frac{3^2-1}8,...,\frac{47^2-1}8$
And so the maximum sum is $\sum_{k=0}^{24}\frac{(2k+1)^2-1}8+\sum_{k=0}^{23}\frac{(2k+1)^2-1}8$
Which is $\boxed{4900}$
My question: Could you please solve the generalize problem? Thank you in advance!