Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

For the array [3, 1, 4, 1, 5, 9, 2, 6], how many subarrays have a product that is a multiple of 6?

  1. A. 20
  2. B. 0
  3. C. 5
  4. D. 60

Correct answer: A. 20

A subarray product is divisible by 6 exactly when it contains a multiple of 2 and a multiple of 3, which can be checked over all 36 subarrays.

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

Exams that ask this topic