Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

What is the sum of i * j over all pairs 1 <= i < j <= 6?

  1. A. 175
  2. B. 176
  3. C. 266
  4. D. 220

Correct answer: A. 175

Use (sum i)^2 minus sum of i^2, halved: (21^2 - 91) / 2 = (441 - 91)/2 = 175. Including the diagonal i = j (second option) adds the squares.

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

Exams that ask this topic