国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

LeetCode 1390. Four Divisors

2023-04-22 16:35 作者:您是打尖兒還是住店呢  | 我要投稿

Given an integer array?nums, return?the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return?0.

?

Example 1:

Input: nums = [21,4,7]

Output: 32

Explanation:?

21 has 4 divisors: 1, 3, 7, 21?

4 has 3 divisors: 1, 2, 4?

7 has 2 divisors: 1, 7?

The answer is the sum of divisors of 21 only.

Example 2:

Input: nums = [21,21]

Output: 64

Example 3:

Input: nums = [1,2,3,4,5]

Output: 0

?

Constraints:

  • 1 <= nums.length <= 104

  • 1 <= nums[i] <= 105

主要就是計算有4個divisor的數(shù)字和,那么我們用set去儲存,遍歷從1到這個數(shù)的平方根,

如果能除盡,那么2個因子都放到set中,最后判斷set的大小為4,則返回每個數(shù)字的和,

如果不是4,返回0;

下面是代碼:

Runtime:?126 ms, faster than?11.96%?of?Java?online submissions for?Four Divisors.

Memory Usage:?43.2 MB, less than?31.58%?of?Java?online submissions for?Four Divisors.


LeetCode 1390. Four Divisors的評論 (共 條)

分享到微博請遵守國家法律
饶河县| 许昌市| 汪清县| 临洮县| 长汀县| 桃江县| 嘉义县| 临朐县| 喜德县| 黄平县| 宝鸡市| 闸北区| 静安区| 水城县| 石台县| 垣曲县| 英山县| 海盐县| 全南县| 晴隆县| 濉溪县| 荃湾区| 普陀区| 天津市| 葵青区| 泽普县| 辽阳市| 墨脱县| 富民县| 原平市| 钦州市| 绍兴市| 化德县| 太保市| 南投市| 昌乐县| 乐亭县| 柘城县| 肇源县| 白水县| 长岛县|