Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

In a 3 × 5 multiplication table (entries i × j for 1 ≤ i ≤ 3, 1 ≤ j ≤ 5), with repeats counted, what is the 7-th smallest entry?

  1. A. 4
  2. B. 5
  3. C. 6
  4. D. 3

Correct answer: A. 4

Binary search a value x and count entries ≤ x, which is Σ over rows i of min(n, floor(x/i)). The smallest x with count ≥ k is the answer; reading off the k-th row or column directly gives a different entry.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic