Problem 878 · Hard

Nth Magical Number

Binary search the answer using inclusion-exclusion to count multiples of a or b up to x.

Open the interactive visualisation