Range Products, Zeros Included
Answer Q range-product queries modulo 109+7 on an array that may contain ZEROS.
Input: the first line has N and Q; the second line has N non-negative integers; the next Q lines have L and R.
Output: Q lines: the product of aL..R mod 109+7.
Constraints:
- 1 ≤ N, Q ≤ 105
- 0 ≤ ai ≤ 109
Sample Tests
Input 1
5 2 2 3 0 4 5 1 2 2 4
Output 1
6 0
Input 2
1 1 0 1 1
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.