Coutinho !

5

1 votes
Problem

Stevie: "Math is so much fun". Also, finally a player that is still at Liverpool :

                                                                     enter image description here

You are given a number K expressed as a product of a given array A of N integers. In short, K=Ni=1A[i] . Now, in addition, you are also given 2 functions that are :

G(i) = smallest divisor of number i greater that 1

F(i) : 0, if i=1.

else F(i) = (1+F(i/G(i)))

Now, you need to answer Q queries. In each query, you shall be given a single number Y. You need to find the sum of all numbers X, such that K is divisible by X. and F(X)=Y

As the answer to this can be rather large, print it Modulo 109+7.

Input Format :

The first line contains 2 space separated integers N and Q. The next line contains N space separated integers, where the ith integer denotes A[i].

Each of the next Q lines contains a single integer Y.

Output Format:

Print the answer to each query on a new line Modulo 109+7

Constraints :

1N5×104

1Q104

0Y104

1A[i]105

Worth 40% of the total score :

1N,A[i],Y,Q5000

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The divisors of the number 36 are :

[1,2,3,4,6,9,12,18,36]

Editor Image

?