Data Structures & AlgorithmsHardGATE CS · ICPC regional
How many integers x with 1 <= x <= 100 satisfy x mod 3 = 2 and x mod 5 = 3?
- A. 8
- B. 7
- C. 6
- D. 10
Correct answer: B. 7
The two congruences combine by the Chinese remainder theorem into x mod 15 = 8, so the solutions are 8, 23, 38, and so on.
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 contiguous subarrays of [7, 1, 6, 13, 8, 2] have a sum congruent to 0 modulo 7?
- How many positive divisors of 720 are perfect squares?
- Two people in a circle of 5 are numbered 1 to 5 and eliminated by repeatedly removing every second person (starting by removing person 2)…
- How many index pairs i < j in the array [1, 2, 3, 4, 5, 6] satisfy gcd(a[i], a[j]) = 1 and a[i] + a[j] is odd?
- What is the number of elements remaining in the list after deleting each element that is smaller than the element immediately before it…
- How many NON-EMPTY subsets of [3, 6, 9, 12, 15, 4, 8, 11] (chosen by index, so equal values are different elements) have a sum divisible…