Class Solution
- java.lang.Object
-
- g0801_0900.s0878_nth_magical_number.Solution
-
public class Solution extends Object
878 - Nth Magical Number.Hard
A positive integer is magical if it is divisible by either
aorb.Given the three integers
n,a, andb, return thenthmagical number. Since the answer may be very large, return it modulo109 + 7.Example 1:
Input: n = 1, a = 2, b = 3
Output: 2
Example 2:
Input: n = 4, a = 2, b = 3
Output: 6
Constraints:
1 <= n <= 1092 <= a, b <= 4 * 104
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intnthMagicalNumber(int n, int a, int b)
-