Multiples of A or B — Solution & Editorial
Inclusion–exclusion: ⌊N/A⌋ + ⌊N/B⌋ − ⌊N/lcm(A,B)⌋. Compute lcm as A/gcd·B to dodge overflow.
Complexity: O(log)
Watch out: lcm(A, B) can exceed 64 bits if computed as A·B first — divide by the gcd before multiplying.