Average Count Array
Submissions: 6183   Accuracy:


  Difficulty: Basic   Marks: 1

You are given an integer 'n' which denote the number of elements in an array a[ ] and an integer 'x'. You have to calculate the average of element a[i] and x and find out if that number exist in array or not. Do it for all the elements of array and store the count result in another array for each index i.

Note:Always take the floor value of the average.

The first line of the input contains an integer T denoting the number of test cases. For each test case there will be two lines. The first line contains n i.e, length of the array a[ ] and value of x. The second line contains the 'n' space seperated integers of the array a[ ].

You have to print the resultant array in which you have to calculate the number of times the average of a[i] and x occurs in the array for each index i.

0 <= T <= 100
0 <= n <= 100
0 <= x <= 100
1 <= a[i] <= 100

5 2
2 4 8 6 2
6 3
9 5 2 4 0 3

2 0 0 1 2

0 1 1 1 0 1


For eg 1: value of n is 5 and that of x is 2. The array is 2 4 8 6 2. We take x i.e. 2 and take average with a[0] whch is equal to 2. We found 2 resides in array at two positions (1st and 5th element) thus storing 2 in another array at 0th index.Similarly do for all elements and store the count in second array.

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

Contributor: Siddhant Manglik
Author: adobe_3128

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.