Data Structures & AlgorithmsVery hardCodeforces Div2 C · TCS NQT

How many unordered pairs of distinct positions in [2, 3, 4, 6, 8, 9, 12] have a product divisible by 6?

  1. A. 17
  2. B. 1
  3. C. 18
  4. D. 15

Correct answer: A. 17

Divisibility of a product depends on the combined prime factors, not on each factor separately: 2 and 3 together make 6 even though neither alone is divisible by 6. Requiring each factor to be divisible by k misses these pairs.

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

Exams that ask this topic