Data Structures & AlgorithmsModerateICPC regional · GATE CS
Problem: The Euler's criterion test: count the quadratic residues modulo 13 among 1 through 12 (a residue r satisfies x² ≡ r for some integer x).
- A. 7
- B. 6
- C. 12
- D. 3
Correct answer: B. 6
Squares mod 13 of x = 1..12 repeat in pairs (x and 13 − x), giving (13 − 1)/2 = 6 distinct residues {1, 3, 4, 9, 10, 12}. Adding 0 gives 7, not removing duplicates gives 12, and 3 counts only perfect squares 1, 4, 9 without reducing mod 13.
More Coding Interview Problems questions
- Problem: How many 4-digit numbers (1000 to 9999) have all four digits distinct and in strictly decreasing order from left to right?
- Problem: Compute the sum of the digits of the number 2^20 × 5^18 written in decimal.
- Problem: Let f(n) = number of 1-bits in n. Compute Σ f(n) for n from 0 to 63 inclusive.
- Problem: Starting at (0,0), the robot moves in the string "NNEESSWWNE" with N = up, E = right, S = down, W = left. Count the number of…
- Problem: The sequence a1 = 2, and each next term is a(n+1) = (a(n) × 3 + 1) mod 11. What is a(20)?
- Problem: A bag holds coins of values 1, 4 and 9. You must pay exactly 30 using as few coins as possible. What is the minimum number of…