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

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
杭州市| 金沙县| 城口县| 沙雅县| 德安县| 阳曲县| 嵊泗县| 拜泉县| 丽江市| 马尔康县| 惠来县| 东光县| 扶余县| 荣昌县| 兴国县| 合川市| 泉州市| 四川省| 襄汾县| 镇雄县| 灵寿县| 临猗县| 铅山县| 浑源县| 赤峰市| 乌兰浩特市| 新蔡县| 布尔津县| 阿拉善盟| 镇坪县| 衡阳市| 竹北市| 南皮县| 合水县| 汕尾市| 大洼县| 沂源县| 安塞县| 都江堰市| 将乐县| 鹤山市|