Data Structures & AlgorithmsVery hardCodeforces Div2 C · TCS NQT

How many unordered pairs of positions in [2, 8, 9, 18, 4, 6, 12] have a product that is a perfect square?

  1. A. 6
  2. B. 4
  3. C. 3
  4. D. 5

Correct answer: B. 4

Reduce each number to its square-free part: a product is a square exactly when the two square-free parts are equal. Counting pairs whose product is divisible by 4 or by 9 measures a different condition.

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

Exams that ask this topic