Data Structures & AlgorithmsHardCAT · Codeforces Div2 B

What is the sum of all integers in [1, 50] that are either perfect squares or perfect cubes?

  1. A. 176
  2. B. 175
  3. C. 177
  4. D. 179

Correct answer: B. 175

Collect the squares 1, 4, 9, ..., 49 and the cubes 1, 8, 27; the number 1 is both and must be counted once.

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

Exams that ask this topic