I have solved the problem by finding the product of all contiguous arrays and the finding out the prime factor of each number and checking First and second subcases are accepted third and fourth is TLE please help !
Instead of doing prime factorization of the product of sub-array every time,precompute the prime factors of every element and store them in an adjacency list .
Here is my accepted solution for reference:
It would be really helpful to follow your code if you could elaborate your logic a bit, Thank you .