Skip to content

Latest commit

 

History

History
139 lines (55 loc) · 1.98 KB

File metadata and controls

139 lines (55 loc) · 1.98 KB

中文文档

Description

A positive integer is magical if it is divisible by either A or B.

Return the N-th magical number.  Since the answer may be very large, return it modulo 10^9 + 7.

 

Example 1:

Input: N = 1, A = 2, B = 3

Output: 2

Example 2:

Input: N = 4, A = 2, B = 3

Output: 6

Example 3:

Input: N = 5, A = 2, B = 4

Output: 10

Example 4:

Input: N = 3, A = 6, B = 4

Output: 8

 

Note:

    <li><code>1 &lt;= N&nbsp;&lt;= 10^9</code></li>
    
    <li><code>2 &lt;= A&nbsp;&lt;= 40000</code></li>
    
    <li><code>2 &lt;= B&nbsp;&lt;= 40000</code></li>
    

Solutions

Python3

Java

...