Maximum Size Set with No Fixed Differences

Problem Statement Given three positive integers $n$, $x$, and $y$, we need to find the maximum size of a set $S$ satisfying: $S \subseteq {1, 2, \ldots, n}$ For any $a \in S$ and $b \in S$, $|a - b| \neq x$ and $|a - b| \neq y$ Output the maximum possible cardinality of $S$. Constraints: $1 \leq n \leq 10^9$, $1 \leq x, y \leq 22$ Observation ...

Posted on Wed, 02 Sep 2026 16:43:33 +0000 by mark bowen