五月天青色头像情侣网名,国产亚洲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的評論 (共 條)

分享到微博請遵守國家法律
襄城县| 阿拉善盟| 嘉定区| 广汉市| 临澧县| 类乌齐县| 中阳县| 兴安盟| 娄烦县| 深泽县| 库车县| 文山县| 临漳县| 武山县| 六枝特区| 祁东县| 连城县| 西青区| 华池县| 揭阳市| 邹城市| 厦门市| 滦南县| 象州县| 新昌县| 开原市| 红河县| 景德镇市| 玉龙| 清新县| 嵊州市| 商河县| 彭阳县| 贵溪市| 陇西县| 伊宁市| 天台县| 五指山市| 郎溪县| 施秉县| 南昌县|