Back to the Problem
Bézout: reachable totals are exactly the multiples of gcd(A, B) up to A+B.
Complexity: O(log)