Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

What is the smallest positive integer x such that floor(x/2) + floor(x/3) is at least 10?

  1. A. 12
  2. B. 11
  3. C. 20
  4. D. 30

Correct answer: A. 12

The function is non-decreasing, so binary search the threshold: x = 11 gives 5 + 3 = 8 and x = 12 gives 6 + 4 = 10. Using ceilings instead of floors gives 11, while keeping only the x/2 term gives 20 and only the x/3 term 30.

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

Exams that ask this topic