Data Structures & AlgorithmsVery hardCodeforces Div2 C · ICPC regional
What is the 10-th smallest positive integer that is divisible by NEITHER 3 nor 5?
- A. 19
- B. 17
- C. 10
- D. 14
Correct answer: B. 17
The count up to x is x − ⌊x/3⌋ − ⌊x/5⌋ + ⌊x/15⌋; the 10th such number is 17 (1, 2, 4, 7, 8, 11, 13, 14, 16, 17). Forgetting to add back ⌊x/15⌋ gives 19, excluding only multiples of 15 gives 10, and excluding only multiples of 3 gives 14.
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 length of the longest substring of "abcbxaxba" that becomes a palindrome after deleting AT MOST ONE character from it?
- How many pairs of positions (i < j) in [5, 2, 7, 2, 9, 1, 6] have a[i] < a[j]?
- Items as (weight, value) are [(4, 6), (2, 3), (5, 9), (3, 4), (6, 10), (1, 1)]. You must take EXACTLY 3 different items with total weight…
- In one operation you may choose a contiguous subarray and increase every element in it by 1. Starting from [0, 0, 0, 0], what is the…
- How many contiguous subarrays of [1, 2, 1, 3, 3, 2, 4, 1] contain EXACTLY 2 distinct values?
- Evaluate 3 + 5 2 - 8 / 4 using standard precedence and integer division. What is the result?