Queries for counts of multiples in an array
Submissions: 1037   Accuracy:

19.03%

  Difficulty: Medium   Marks: 4

Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of three lines. First line of each test case contains two integers N & M, second line contains N space separated array elements and third line contains M space
separated  queries.

Output:
For each test case,In new line print the required count for each query Q[i].

Constraints:
1<=T<=100
1<=N,M<=105
1<=A[i],Q[i]<=105

Example:
Input:

2
6 3

2 4 9 15 21 20
2 3 5
3 2

3 4 6
2 3

Output:
3 3 2
2 2

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.