#P5366. [SNOI2017] 遗失的答案

[SNOI2017] 遗失的答案

Description

After calculating the answer, Little Ball bought a bunch of skins. He was very happy, but by accident, he forgot which skins he had bought. = =|||

Fortunately, he still remembers that he numbered all skins from 1N1 \sim \text{N}. Among the skins he bought (he bought at least one skin), the greatest common divisor is G\text{G}, and the least common multiple is L\text{L}.

Now there are Q\text{Q} queries. Each query gives a number X\text{X}. Please tell Little Ball: among all valid purchase plans, how many of them include skin X\text{X}?

Because the answer is too large, you only need to output the answer mod109+7\bmod{10^9+7}.

Input Format

The first line contains three integers N, G, L\text{N, G, L}, as described.

The second line contains one integer Q\text{Q}, the number of queries.

The third line contains Q\text{Q} integers, each being the X\text{X} asked in a query.

Output Format

For each query, output one integer per line, representing the answer to this query.

5 1 30
5
1 2 3 4 5
1
2
2
0
2

Hint

30%30\% of the testdata: N20\text{N} \le 20.

50%50\% of the testdata: N1000\text{N} \le 1000.

70%70\% of the testdata: N100000\text{N} \le 100000.

100%100\% of the testdata: $\text{N, G, L} \le 10^8, \text{Q} \le 10^5, 1 \le \text{X} \le 10^8$.

Translated by ChatGPT 5