Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

How many integers x in [1, 100] can be written as a^2 + b^2 with positive integers a and b?

  1. A. 36
  2. B. 37
  3. C. 39
  4. D. 35

Correct answer: D. 35

Enumerate a and b up to 10, collect the distinct sums up to 100 in a set, and count; a sum such as 25 = 3^2 + 4^2 is counted once however it is reached.

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

Exams that ask this topic