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)/第 K 个最小的素数分数 [k-th-smallest-prime-fraction].html
2022-03-29 12:43:11 +08:00

37 lines
1.5 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>给你一个按递增顺序排序的数组 <code>arr</code> 和一个整数 <code>k</code> 。数组 <code>arr</code><code>1</code> 和若干 <strong>素数</strong>&nbsp; 组成,且其中所有整数互不相同。</p>
<p>对于每对满足 <code>0 &lt;= i &lt; j &lt; arr.length</code><code>i</code><code>j</code> ,可以得到分数 <code>arr[i] / arr[j]</code></p>
<p>那么第&nbsp;<code>k</code>&nbsp;个最小的分数是多少呢?&nbsp; 以长度为 <code>2</code> 的整数数组返回你的答案, 这里&nbsp;<code>answer[0] == arr[i]</code>&nbsp;&nbsp;<code>answer[1] == arr[j]</code></p>
&nbsp;
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>arr = [1,2,3,5], k = 3
<strong>输出:</strong>[2,5]
<strong>解释:</strong>已构造好的分数,排序后如下所示:
1/5, 1/3, 2/5, 1/2, 3/5, 2/3
很明显第三个最小的分数是 2/5
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>arr = [1,7], k = 1
<strong>输出:</strong>[1,7]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= arr.length &lt;= 1000</code></li>
<li><code>1 &lt;= arr[i] &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>arr[0] == 1</code></li>
<li><code>arr[i]</code> 是一个 <strong>素数</strong> <code>i &gt; 0</code></li>
<li><code>arr</code> 中的所有数字 <strong>互不相同</strong> ,且按 <strong>严格递增</strong> 排序</li>
<li><code>1 &lt;= k &lt;= arr.length * (arr.length - 1) / 2</code></li>
</ul>