Help needed in LCM range query problem

Given an array A of N (N<=2*10^4) elements and Q(Q<=10^6) queries. Each array element A[i]<=60.

In each query you are given a number K (K<=N). Compute LCM for all subarrays of size K and report the smallest value of LCM found.
Please suggest some approach for this problem.

Please post the link of the question for which you ask for help. It makes for us easy to verify our approach, before answering the question.

http://codeforces.com/problemset/gymProblem/100570/A

I tried storing precomputed results for subarrays of size<=sqrt(N) and for subarrays with size>sqrt(N), I used the brute force way but got TLE.

http://codeforces.com/blog/entry/15722

The tutorial for the problem. It is on right panel on codeforces under contest materials

I am looking for some other approach possible to solve this problem