Data Structures & AlgorithmsModerateICPC regional · Codeforces Div2 B
Problem: Compute the 50th Fibonacci number F(50) with F(1) = F(2) = 1, modulo 1,000,000,007.
- A. 586268941
- B. 778742000
- C. 365010934
- D. 586269025
Correct answer: A. 586268941
F(50) = 12586269025, and iterating with a reduction mod 1,000,000,007 at every step gives 586268941. An off-by-one index gives F(49) → 778742000 or F(51) → 365010934, and reducing mod 10⁹ instead of 10⁹ + 7 gives 586269025.
More Coding Interview Problems questions
- Problem: Compute C(20, 10) modulo 1,000,000,007 (the binomial coefficient).
- Problem: How many prime numbers are there up to 100 (inclusive)?
- Problem: What is the LCM of the array [4, 6, 10, 15]?
- Problem: Count the pairs (i, j) with i < j in the array [1, 2, ..., 10] whose sum is divisible by 4.
- Problem: Find the majority element (appearing more than half the time) of [2, 2, 1, 1, 1, 2, 2] using the Boyer–Moore voting algorithm…
- Problem: Kadane's algorithm finds the maximum sum of a non-empty contiguous subarray of [−2, 1, −3, 4, −1, 2, 1, −5, 4]. What is that…