五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網 會員登陸 & 注冊

LeetCode 1362. Closest Divisors

2023-08-14 12:41 作者:您是打尖兒還是住店呢  | 我要投稿

Given an integer?num, find the closest two integers in absolute difference whose product equals?num + 1?or?num + 2.

Return the two integers in any order.

?

Example 1:

Input: num = 8

Output: [3,3]

Explanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen.

Example 2:

Input: num = 123

Output: [5,25]

Example 3:

Input: num = 999

Output: [40,25]

?

Constraints:

  • 1 <= num <= 10^9


Hide Hint 1

Find the divisors of n+1 and n+2.

Hide Hint 2

To find the divisors of a number, you only need to iterate to the square root of that number.


Runtime:?6 ms, faster than?82.52%?of?Java?online submissions for?Closest Divisors.

Memory Usage:?40.3 MB, less than?28.16%?of?Java?online submissions for?Closest Divisors.

--------------------------------------

依次遍歷即可:

下面是代碼:


LeetCode 1362. Closest Divisors的評論 (共 條)

分享到微博請遵守國家法律
屯昌县| 左权县| 乌拉特中旗| 汉中市| 平凉市| 叙永县| 大埔区| 广昌县| 浦江县| 同江市| 清镇市| 芜湖县| 资中县| 马尔康县| 繁昌县| 承德市| 乳山市| 景东| 江源县| 保德县| 凤凰县| 丹棱县| 双桥区| 晋中市| 揭西县| 东城区| 鸡泽县| 德令哈市| 江北区| 石台县| 珠海市| 海安县| 宿迁市| 韩城市| 鸡泽县| 大田县| 灌南县| 石泉县| 临泽县| 岫岩| 琼中|