Problem

Source: 2012 USAJMO Day 2 #5

Tags: 2012 USAJMO



For distinct positive integers $a, b<2012$, define $f(a, b)$ to be the number of integers $k$ with $1\le k<2012$ such that the remainder when $ak$ divided by $2012$ is greater than that of $bk$ divided by $2012$. Let $S$ be the minimum value of $f(a, b)$, where $a$ and $b$ range over all pairs of distinct positive integers less than $2012$. Determine $S$.