Problem

Source: ELMO 2023/2

Tags: Elmo, number theory, combinatorics



Let \(a\), \(b\), and \(n\) be positive integers. A lemonade stand owns \(n\) cups, all of which are initially empty. The lemonade stand has a filling machine and an emptying machine, which operate according to the following rules: If at any moment, \(a\) completely empty cups are available, the filling machine spends the next \(a\) minutes filling those \(a\) cups simultaneously and doing nothing else. If at any moment, \(b\) completely full cups are available, the emptying machine spends the next \(b\) minutes emptying those \(b\) cups simultaneously and doing nothing else. Suppose that after a sufficiently long time has passed, both the filling machine and emptying machine work without pausing. Find, in terms of \(a\) and \(b\), the least possible value of \(n\). Proposed by Raymond Feng