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?
- A. 12
- B. 11
- C. 20
- 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.
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
- In [3, 8, 1, 8, 5], you move the rightmost occurrence of the maximum to the last position using adjacent swaps. How many adjacent swaps…
- How many unordered pairs of distinct words in ["abc", "aba", "cdc", "xyz", "axa", "cd"] share both the same first letter and the same last…
- How many index pairs i < j of [1, 2, 5, 7, 10] have absolute difference at least 3?
- Numbers 1, 2, 3, 4 are pushed in this order onto a stack. Can the pop sequence 3, 4, 2, 1 be produced?
- How many length-3 substrings of "abcabc" are rotations of "abc" (namely abc, bca or cab)?
- What is the sum of the decimal digits of 2^20?