Query of prime factors

If the query be like “Find the number of distinct prime factors of the product of all elements of the sub array”

For example if the array be like [2 4 3 15 16] (zero based indexing)
then the query on (0 to 2) should return answer as 2.

Because distinct prime factors of 2,4,3 are 2 & 3.

Can anyone please suggest a efficient solution to this assuming size of array be n<10^5
& number of queries q <=2^n ?

Time limit be 1 seconds .

Not 100% sure but maybe you can use this or other solutions from the same editorial.

1 Like