Description
Input
The first line, and two positive integers S q, q represents the number of inquiries.
Next q lines each a positive integer n.
Output
The output common line q, respectively, for each answer to the inquiry.
Sample Input
9
29
1000000000000000000
Sample Output
9
450000036
HINT
Thanks to the Loser help correct the data
To 100% of the data, 2 <= S <= 2 * 10 ^ 6,1 <= n <= 10 ^ 18,1 <= q <= 10 ^ 5
This problem surfaces can be confusing ah
In fact, the meaning of problems was quite simple
First, the decomposition of the quality factor S
If you have the same factor appears more than once, then $ lcm (p_1, p_2, p_3 ... p_k) = S $ must not be satisfied
At this time, a direct Japanese sentence output Q to 0
(This is so good 10 minutes to get what want positive solutions hhh)
The next step is to take a certain amount for each $ p_i $, and to make their $ n $
Suppose $ n = \ sum {p_i * c_i} $, $ P_i i.e. corresponding to fetch $ $ $ a C_i
$ $ P_i is a factor of S, available $ p_i * c_i $ constant can be expressed as $ X * S + Y * p_i $
The other $ $ P_i past, to give $ c_i = X * \ frac {S} {p_i} + Y $