Vasya and Mathematical Analysis
Practice
0 (0 votes)
Mathematics
Sieve
Easy Medium
Number theory
Factorization
Problem
29% Success 2673 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

It's an extremely cold day in BitLand and Vasya is in the mood to do some complex arithmetic. So, he defines the following 2 functions:

\(F(x)\) : Largest divisor of number x that is \(< x\).

\(Q(A,l,r)\): Product of \(F(x)\) where \(l \le x \le r\) in a certain array A

Now, Vasya has been given an array A of size N. He needs to answer certain types of queries based on this array. In each query. he shall be given 2 integers l and r and he needs to find \(Q(A,l,r)\) He find this task too easy and has passed it on to you. Can you do it. As the answer to each query can be relatively large, find it Modulo \(10^9+7\)

Input Format :

The first line contains a single integers N denoting the size of array A. The next line contains N space separated integers denoting the elements of array A. The next line contains a single integer T denoting the number of queries. Each of the next T lines contain 2 integers l and r.

Output Format:

Print the answer to each query on a new line. As the answer may be large, print it Modulo \(10^9+7\)

Constraints:

\( 1 \le N \le 10^6 \)

\( 2 \le A[i] \le 10^7 \)

\( 1 \le T \le 10^5 \)

\( 1 \le l \le r \le N \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
4 votes
Tags:
Number TheoryPrime FactorizationEasy-MediumMathematicsSieveFactorization
Points:30
Tags:
MathematicsEasy-MediumFactorization
Points:30
1 votes
Tags:
Dynamic ProgrammingPrime FactorizationEasy-MediumMathematicsGame TheoryFactorization