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?
- A. 36
- B. 37
- C. 39
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is 2^100 mod 7?
- Every element of the circular array [1, 2, 3, 4] is replaced by the sum of its two circular neighbours, taken modulo 10, simultaneously…
- How many pairs a < b with 1 <= a < b <= 12 satisfy gcd(a, b) = b - a?
- How many integers n in [1, 60] satisfy n^2 - n divisible by 6?
- What is the length of the longest contiguous subarray of [4, 3, 2, 6, 1, 5] whose sum is at most 10?
- How many times does the pattern aab occur in the string aabaabaab, counting overlapping matches?