Data Structures & AlgorithmsModerateICPC regional · TCS NQT

Problem: Compute (1³ + 2³ + … + 100³) modulo 1000.

  1. A. 50
  2. B. 775
  3. C. 500
  4. D. 350

Correct answer: C. 500

Σk³ = (n(n+1)/2)² = 5050² = 25502500, so the answer is 500. Not squaring gives 5050 mod 1000 = 50, applying n(n+1)/2 again gives 775, and Σk² = 338350 gives 350.

More Coding Interview Problems questions

Exams that ask this topic