Leaderboard
Showing:
Queries for counts of multiples in an array
Medium Accuracy: 24.49% Submissions: 1294 Points: 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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Queries for counts of multiples in an array

Output Window