首页 > 其他 > 详细

[LeetCode] 878. Nth Magical Number 第N个神奇数字

时间:2019-07-08 00:19:42      阅读:194      评论:0      收藏:0      [点我收藏+]



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:

  1. 1 <= N?<= 10^9
  2. 2 <= A?<= 40000
  3. 2 <= B?<= 40000



Github 同步地址:

https://github.com/grandyang/leetcode/issues/878



参考资料:

https://leetcode.com/problems/nth-magical-number/



LeetCode All in One 题目讲解汇总(持续更新中...)

[LeetCode] 878. Nth Magical Number 第N个神奇数字

原文:https://www.cnblogs.com/grandyang/p/11148889.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!