values: it starts with 1, and every other element is a distinct prime. You are also given an integer rank.
For every pair of indices i < j, form the fraction values[i] / values[j]. All these fractions are distinct. Sort them in increasing order and find the rank-th one (1-based).
Return it as [numerator, denominator], i.e. [values[i], values[j]].
Listing all O(n²) fractions is easy; try to find the answer faster.values=[1, 3, 7, 11], rank=4 → [1, 3]
All fractions in increasing order: 1/11, 1/7, 3/11, 1/3, 3/7, 7/11. The fourth is 1/3.
values=[1, 2, 5], rank=3 → [1, 2]
The fractions are 1/5, 2/5, 1/2. The third and largest is 1/2.
values=[1, 13], rank=1 → [1, 13]
values) ≤ 1000values[0] = 1 and every other element is primevalues is strictly increasing, values[i] ≤ 3·10⁴rank ≤ n·(n − 1) / 2, where n = len(values)values=[1, 3, 7, 11], rank=4
[1, 3]
Run checks the first 3 tests in your browser. Submit checks all 54 tests on the server, hidden ones included.