Given a positive integer n, consider an array powers consisting of the minimum number of powers of n, sorted in ascending order.
You are also given a queries, where each queries[i] = [start_i, end_i]. For each query, compute the product of all elements from powers[start_i] through powers[end_i] inclusive.
Return an array where each element is the result of the corresponding query.
Note: Since the results may be large, return each answer modulo
.
Constraints:
n
queries.length
start_i end_i powers.length
Given a positive integer n, consider an array powers consisting of the minimum number of powers of n, sorted in ascending order.
You are also given a queries, where each queries[i] = [start_i, end_i]. For each query, compute the product of all elements from powers[start_i] through powers[end_i] inclusive.
Return an array where each element is the result of the corresponding query.
Note: Since the results may be large, return each answer modulo
.
Constraints:
n
queries.length
start_i end_i powers.length