Data Structures & AlgorithmsHardGATE CS · ICPC regional
What is the value of the expression (1^2) + (2^2) + ... + (50^2) modulo 7?
- A. 1
- B. 2
- C. {C+5}
- D. 4
Correct answer: A. 1
Reduce each square modulo 7 first; squares repeat with period 7, so each block of seven terms contributes the same residue.
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
- How many ordered pairs (a, b) with 1 <= a, b <= 30 satisfy a^2 + b^2 divisible by 7?
- A bank of 4 workers each processes one task per minute, and tasks arrive as a queue. In a single pass over the array of task lengths [3…
- How many subarrays of [3, 1, 4, 1, 5] have their minimum equal to their first element?
- What is the minimum possible value of the largest sum among the two groups when the array [7, 2, 5, 10, 8] is split into two contiguous…
- How many indices i in [1, 500] satisfy both that i is divisible by 3 and that i+1 is divisible by 5?
- What is the number of occurrences of the substring ana in bananaanana, counting overlapping occurrences?