Data Structures & AlgorithmsVery hardCAT · Codeforces Div2 B
How many indices i in [1, 500] satisfy both that i is divisible by 3 and that i+1 is divisible by 5?
- A. 166
- B. 33
- C. 100
- D. 233
Correct answer: B. 33
i ≡ 0 (mod 3) and i ≡ 4 (mod 5) combine by CRT to i ≡ 9 (mod 15): 9, 24, ..., 489 = 33 values. 166 checks only divisibility by 3, 100 only the second condition, and 233 counts numbers meeting either condition.
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 number of occurrences of the substring ana in bananaanana, counting overlapping occurrences?
- How many index pairs i < j in [1, 2, 3, 2, 1, 4] have a[i] + a[j] equal to 3 or to 6?
- How many distinct cells are visited when a robot starts at (0, 0) and makes the moves R, U, R, D, L, U, U (R: x+1, L: x-1, U: y+1, D…
- What is the smallest positive integer that is divisible by every integer from 1 to 12 and is also a perfect square?
- A string is compared to a pattern by repeatedly rotating its first character to the end. How many distinct rotations of abab exist…
- What is the length of the longest substring of abcabdabcd that contains at most two distinct characters?