Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

What is the smallest positive integer x such that x^2 + x is at least 1000?

  1. A. 32
  2. B. 31
  3. C. 10
  4. D. 500

Correct answer: A. 32

x² + x is increasing, so scan or binary search: 31 gives 992 and 32 gives 1056. 31 is the last failing value, 10 solves x³ + x ≥ 1000, and 500 treats the expression as x + x.

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

Exams that ask this topic