Ratio of sum in black and white squares For even positive integer $n$ we put all numbers $1,2,...,n^2$ into the squares of an $n\times n$ chessboard (each number appears once and only once).
Let $S_1$ be the sum of the numbers put in the black squares and $S_2$ be the sum of the numbers put in the white squares. Find all $n$ such that we can achieve $$\frac{S_1}{S_2}=\frac{39}{64}.$$
This is a problem from Greece MO 2014. I have reached that $103S_1=32n^2(n^2+1)$ and hence $103\mid n$ but I haven't progressed a bit about which $n$. Can someone help? Thanks in advance.
 A: You already know that 103|n. This is also sufficient. First, suppose the minimum value of S1 (obtained by taking $1, 2, ... \lfloor(n^2/2)\rfloor$ in black squares is x. Also, call sum of all numbers from 1 to $n^2$ as y. In other words, maximum value of S1 is y - x.
I will show that S1 can take any value from x to y - x. Here is how:
Suppose the sequence of numbers in black squares, in increasing order, is $P1 = (s_1, s_2, \cdots, s_k)$. I claim that I can increase the sum by exactly 1, unless P1 already leads to the highest S1. Here is is now:
If P1 does not lead to the highest S1, then either $s_k$ is less than $n^2$, or there exists an index i such that $s_{i+1} - s_i$ > 1. (Why? If none of these conditions is met, we are left with a P1 that leads to the highest S1).
In each of these cases, we can create a P2 whose sum is greater than that of P1 by exactly 1. We can do this by changing exactly one element in P2 compared to P1. Here is how:
In the first case, replace $s_k$ by $s_k + 1$.
In the second case, replace $s_i$ by $s_i + 1$.
As you can see, we can always perform one of these operations unless P1 already leads to the highest possible S1.
Therefore, we can find allocations of numbers to squares that attain all possible values of S1 from the minimum to the maximum.
So all you need to show is that $39/103*n^2(n^2+1)/2$ does lie in this range in case 103 divides n. I guess you should be able to work through the details?
Roughly speaking, $\frac{(k(k+1)/2)}{(2k(2k+1))/2}$ is around 0.25. So all ratios from 0.25 to 0.75 where the denominator is reasonable can be reached. There are some boundary cases to deal with, but 39/103 lies well within this range and won't be affected by this for reasonably large n (and even n=103 is reasonably large here).
