Range LCM Queries
Submissions: 267   Accuracy:

53.56%

  Difficulty: Medium
       

Given an array of integers, evaluate queries of the form LCM(l, r). There might be many queries, hence evaluate the queries efficiently.

Input:
The first line of input contains an integer t denoting the number of test cases. Then T test cases follow. Each test case contains two integers n denoting the size of the array and number of queries. The next line contains n space separated integers forming the array. The last line contains the range a and b for each query.

Output:
Print the lcm for each query.

Constraints:
1<=T<=100
1<=n<=100
1<=data of node<=100
1<=no of queries<=100
0<=a<=n
a<=b<=n

Example:
Input:

1
11 3
5 7 5 2 10 12 11 17 14 1 44
2 5 5 10 0 10

Output:
60 15708 78540

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.