Data Structures & AlgorithmsVery hardCodeforces Div2 C · ICPC regional

What is the 10-th smallest positive integer that is divisible by NEITHER 3 nor 5?

  1. A. 19
  2. B. 17
  3. C. 10
  4. 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.

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

Exams that ask this topic