Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
What is the smallest positive integer x such that x^2 + x is at least 1000?
- A. 32
- B. 31
- C. 10
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many index pairs i < j in [1, 4, 6, 3, 2] satisfy a[i] XOR a[j] < min(a[i], a[j])?
- In "xxyxxzxxx", what is the length of the longest substring that contains at most one character other than 'x'?
- How many index pairs i < j of [1, 2, 3, 4, 5] have a sum equal to the array's maximum?
- Keeping only a palindrome (as a subsequence) of "abcba" needs no deletion at all, since the string is a palindrome already. What is the…
- What is the maximum number of pairwise disjoint contiguous subarrays of [2, 3, 1, 4, 2, 3, 5] that each have sum at least 5 (taken from…
- How many integers n with 1 <= n <= 200 have both n and n + 2 prime?