classSolution: defsmallestDivisor(self, nums: List[int], threshold: int) -> int: defsearch_II(check) ->int: # 二分法目标:找除数 nums.sort() left = 1 right = nums[len(nums)-1] while left<=right: mid = (left+right)>>1 if check(mid): right = mid-1 else: left = mid+1 return left defcheck(x) ->bool: ans = 0 for i in nums: if i%x!=0: ans += i//x + 1 else: ans += i//x print(x,"is x",ans,"is sum") return ans <= threshold return search_II(check)