Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
What is the smallest positive integer x such that the sum of floor(x / a_i) over a = [2, 3, 5] is at least 20?
- A. 20
- B. 21
- C. 22
- D. 23
Correct answer: A. 20
The function sum(floor(x / a_i)) is non-decreasing in x, so binary search finds the first x that reaches 20. Checking at the boundary value gives a different threshold.
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
- What is the lexicographically smallest subsequence of length 3 of "cbacdcbc"?
- How many positive divisors of 2^5 3^2 7 are odd?
- How many non-empty contiguous subarrays of [3, 3, 1, 2, 2, 1] have bitwise XOR equal to 0?
- How many distinct palindromic substrings (as strings, not positions) does "aaaa" have?
- A road of length 24 has fuel stations at kilometres 3, 7, 9, 14, 17, 22. The car starts at 0 and has range 8 km per tank (it refuels fully…
- Buildings of heights [4, 1, 6, 2, 5, 3] are viewed from the right. How many are visible (strictly taller than every building to their…