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?
- A. 7
- B. 6
- C. 20
- 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.
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 sum of an = n mod 7 for n from 1 to 20 inclusive?
- From [1, 2, 2, 3, 5, 6, 6], what is the maximum number of disjoint pairs where the two values differ by at most 1?
- How many integers from 1 to 64 inclusive have a binary representation (without leading zeros) that reads the same forwards and backwards?
- What is the minimum number of characters that must be inserted anywhere in "abcb" to make it a palindrome?
- How many windows of size 4 in [1, 2, 1, 3, 4, 2, 5, 6] contain four pairwise distinct values?
- What is the smallest positive integer n such that n! ends in exactly 10 trailing zeros?