Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B
How many integers x with 1 <= x <= 100 satisfy x^2 mod 24 = 1?
- A. 34
- B. 33
- C. 32
- D. 36
Correct answer: B. 33
Residues mod 24 whose square is 1 are exactly the units that are their own inverse. Counting residues first avoids checking every x by hand.
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 (i, j) with 1 <= i, j <= 18 have i j divisible by 18?
- How many contiguous subarrays of [2, 8, 3, 3, 2, 6] have a product that is a perfect square?
- How many contiguous subarrays of [1, 3, 2, 6, 4, 2] have a sum divisible by their length?
- Evaluate the integer expression 2 - 3 4 + 10 / 3 using standard precedence and integer division that truncates toward zero. What is the…
- What is the length of the longest run of consecutive integers (in any order) present in the array [9, 1, 4, 7, 3, -1, 0, 5, 8, -1, 6]?
- How many index pairs i < j in the array [1, 5, 3, 4, 2, 7, 9] have absolute difference exactly 2?