IMC 2013 · Problem 2

Day 220th IMC · Blagoevgrad, Bulgaria

Statement

Let pp and qq be relatively prime positive integers. Prove that

∑k=0pq−1(−1)⌊kp⌋+⌊kq⌋={0if pq is even,1if pq is odd.(∗)\sum_{k=0}^{pq-1} (-1)^{\left\lfloor \frac{k}{p} \right\rfloor + \left\lfloor \frac{k}{q} \right\rfloor} = \begin{cases} 0 & \text{if } pq \text{ is even}, \\ 1 & \text{if } pq \text{ is odd}. \end{cases} \tag{$*$}

(Here ⌊x⌋\lfloor x \rfloor denotes the integer part of xx.)

Official solution

Hidden so you can work on the problem first.

Proposed by Alexander Bolbot, State University, Novosibirsk.