Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

How many index pairs i < j in [0, 1, 2, 3, 4] satisfy a[i] + a[j] = a[i] * a[j]?

  1. A. 0
  2. B. 1
  3. C. 2
  4. D. 10

Correct answer: A. 0

Rewrite a + b = ab as (a - 1)(b - 1) = 1. Only a = b = 0 or a = b = 2 satisfy it, and those need repeated values, so the count is 0.

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

Exams that ask this topic