1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/使结果不超过阈值的最小除数 [find-the-smallest-divisor-given-a-threshold].html
2022-03-29 12:43:11 +08:00

43 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组&nbsp;<code>nums</code> 和一个正整数&nbsp;<code>threshold</code> &nbsp;,你需要选择一个正整数作为除数,然后将数组里每个数都除以它,并对除法结果求和。</p>
<p>请你找出能够使上述结果小于等于阈值&nbsp;<code>threshold</code>&nbsp;的除数中 <strong>最小</strong> 的那个。</p>
<p>每个数除以除数后都向上取整,比方说 7/3 = 3 10/2 = 5 。</p>
<p>题目保证一定有解。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,5,9], threshold = 6
<strong>输出:</strong>5
<strong>解释:</strong>如果除数为 1 ,我们可以得到和为 17 1+2+5+9
如果除数为 4 ,我们可以得到和为 7 (1+1+2+3) 。如果除数为 5 ,和为 5 (1+1+1+2)。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [2,3,5,7,11], threshold = 11
<strong>输出:</strong>3
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [19], threshold = 5
<strong>输出:</strong>4
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 5 * 10^4</code></li>
<li><code>1 &lt;= nums[i] &lt;= 10^6</code></li>
<li><code>nums.length &lt;=&nbsp;threshold &lt;= 10^6</code></li>
</ul>