精華區beta Marginalman 關於我們 聯絡資訊
第一題 照題目敘述寫 Python Code: class Solution: def canAliceWin(self, nums: List[int]) -> bool: count = 0 for n in nums: if n < 10: count += n k = sum(nums) if (k-count) > count or count > (k-count): return True else: return False 第二題 其實就找質數的平方數 只是不能直接整個查找 不然會TLE Python Code: class Solution: def nonSpecialCount(self, l: int, r: int) -> int: def is_prime(num): if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True special_count = 0 p = int(l ** 0.5) while p ** 2 <= r: if is_prime(p): square = p ** 2 if l <= square <= r: special_count += 1 p += 1 total_numbers = r - l + 1 return total_numbers - special_count 第三題 應該是sliding window 不過有點想睡 放棄 大家加油 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.137.59.5 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1722136927.A.76E.html
Smallsh: 大師 07/28 11:22
DJYOMIYAHINA: 大濕 我今天0題 07/28 11:46
sustainer123: 要是我有工作 我也0題 唉 07/28 11:49
dont: 第4題 對可連接的circle做union find 07/28 11:58
dont: 再看圓碰到幾個邊或(X,Y),(0,0) 07/28 11:59
sustainer123: 我只感覺是graph 但完全沒想法 07/28 12:02