A positive integer is magical if it is divisible by a or by b. Given n, a, and b, return the n-th smallest magical number, modulo 1,000,000,007. Use binary search with inclusion-exclusion counting. Input: 'n, a, b'.
Input: 'n, a, b'.
Output: Integer — the n-th magical number mod 1e9+7.
Input: 4, 2, 3
Output: 6
Explanation: Magical numbers 2,3,4,6: 4th is 6.Input: 1, 2, 3
Output: 2
Explanation: First magical number.Input: 5, 2, 4
Output: 10
Explanation: 5th magical number.1<=n<=10^92<=a,b<=4*10^4