#C11093. Subarray Product Queries
Subarray Product Queries
Subarray Product Queries
You are given a series of operations on an initially empty array. There are two types of operations:
- Operation 1 (Insertion): "1 x" means append the integer x to the array.
- Operation 2 (Query): "2 a b" means compute the product of the subarray from index a to b (inclusive, 1-indexed) modulo \(10^9+7\). That is, if the subarray elements are \(x_a, x_{a+1}, \dots, x_b\), then output \(x_a \times x_{a+1} \times \cdots \times x_b \bmod (10^9+7)\).
You are given several test cases to process. For each test case, execute the operations in the given order and output the result of each query operation on a new line.
inputFormat
The input is read from stdin and has the following format:
T m operation_1 operation_2 ... operation_m ... (repeat for T test cases)
Where:
- T is the number of test cases.
- For each test case, an integer m is given representing the number of operations.
- Each of the next m lines is an operation in one of the following forms:
- "1 x" indicates an insertion of integer x.
- "2 a b" indicates a query to compute the product of the subarray from index a to b (1-indexed).
outputFormat
For each query operation encountered in the order of input, output the result (the product modulo \(10^9+7\)) on a separate line to stdout.
## sample1
5
1 4
1 5
1 3
2 1 2
2 1 3
20
60
</p>