Tap here to switch tabs
Problem
Submissions

Problem: Range Product Queries of Powers

med
30 min
Try to solve the Range Product Queries of Powers problem.

Statement

Given a positive integer n, consider an array powers consisting of the minimum number of powers of 22 that sum up to n, sorted in ascending order.

You are also given a 22D integer array 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 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • 0≤0 \leq start_i ≤\leq end_i << powers.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Range Product Queries of Powers

med
30 min
Try to solve the Range Product Queries of Powers problem.

Statement

Given a positive integer n, consider an array powers consisting of the minimum number of powers of 22 that sum up to n, sorted in ascending order.

You are also given a 22D integer array 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 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • 0≤0 \leq start_i ≤\leq end_i << powers.length