Here is another task for you, prepared by Monk himself. So, this is how it goes :
Given an integer array A of size N, Monk needs you to answer T queries for him. In each query, he gives you 2 integers P and Q. In response to each of these queries, you need to tell Monk the count of numbers in array A. that are either divisible by P, Q, or both.
Can you cope with this ?
Video approach to solve this question: here
Input Format :
The first line contains a single integer N denoting the size of array A. The next line contains N space separated integers, where the ith integer denotes A[i].
The next line contains a single integer T denoting the number of queries Monk poses to you. Each of the next T lines contains 2 space separated integers P and Q.
Output Format :
For each query, print the answer on a new line.
Constraints :
1≤N≤2×105
1≤A[i]≤2×105
1≤T≤2×105
1≤P,Q≤2×105
For the 1st query in the 1st sample, the numbers that form a part of the count are 4 and 5, present at indices 5 and 3 respectively.