Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

How many distinct values does floor(n / 3) take as n ranges over 1 to 20 inclusive?

  1. A. 7
  2. B. 6
  3. C. 20
  4. D. 3

Correct answer: A. 7

⌊n/3⌋ for n = 1..20 runs through 0, 1, ..., 6, so 7 distinct values. Forgetting the value 0 (n = 1, 2) gives 6, 20 counts the inputs rather than the values, and 3 is the divisor.

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

Exams that ask this topic