Akash and Equal Mean Codechef Solution | APRIL CHALLENGE

Codechef
Share:

Akash and Equal Mean Codechef Solution

Akash goes to class everyday. His classes are held on the 9th9th floor so he uses a lift. One day NN people get on the lift. However, since the lift can carry at most N−2N−2 people, 22 of them need to get off.

Given an array AA of the weights of the NN people, Akash wonders how many ways of removing 22 people exist such that the mean of weights of the people in the lift remains constant. In other words, the mean of weights of the N−2N−2 people remaining in the lift must be the same as the mean of weights of all the NN people who were initially on the lift. Help Akash find how many such ways exist.

Input Format

  • The first line contains a single integer TT – the number of test cases. Then the test cases follow.
  • The first line of each test case contains an integer NN – the number of people who get on the lift initially.
  • The second line of each test case contains NN space-separated integers A1,A2,…,ANA1,A2,…,AN denoting the weights of the NN people on the lift.

Output Format

For each test case, print a single integer denoting the number of ways of removing 22 people such that the mean reamins the same.

Constraints

  • 1≤T≤10001≤T≤1000
  • 3≤N≤1053≤N≤105
  • 1≤Ai≤1091≤Ai≤109
  • Sum of NN over all test cases does not exceed 2⋅1052⋅105

Sample Input 1 

3
4
1 3 5 7
4
1 7 7 7
6
1 1 1 1 1 1

Sample Output 1 

2
0
15

Explanation

Test case 11: The mean of weights of all NN students is 1+3+5+74=164=41+3+5+74=164=4.

  • Consider removing the people with weights (1,7)(1,7). The mean of weights of the N−2N−2 people remaining in the lift is 3+52=82=43+52=82=4, which is same as the mean of all NN people.
  • Consider removing the people with weights (3,5)(3,5). The mean of weights of the N−2N−2 people remaining in the lift is 1+72=82=41+72=82=4, which is same as the mean of all NN people.

There is no other way to remove 22 people such that the mean reamins the same. Hence the answer is 22.

Test case 22: The mean of weights of all NN students is 1+7+7+74=5.51+7+7+74=5.5. It can be seen that there is no way to remove 22 people such that the mean reamins the same. Hence the answer is 00.

Akash and Equal Mean Codechef  SOLUTION

Download Code
login to google play console, youtube video search by image, how to add a google account, which are the google apps, what is the google app, how to add a new google account, all the google apps, which service is the part of google, adsetting google, google data studio, google DNS, GCP console, bigquery, google studio, google api console, google app engine, anthos, google apis, google public DNS, google audio, google launcher, gcloud console, google compute engine, google webmaster console, google logged-in devices, gdrive unlimited,google console tools,google studio login,my google voice,hey google service,find similar images google, my google forms, www google com bd search, search using images in google,google image search scan,google sea console,website console google, google sound, gdrive storage for students, google site console, google console login, webmaster console, searc h console, google server down, google backup login, photo finder google, google products and services, google console tool, google image check, google cloud search is used for, google dashboard studio, google voice and audio activity,gcp dashboards, google services down, google go app, google dns down, google image identifier,check picture on google,google new launcher,google image finder online,image check google google google go, image finder on google, finding images on google, photo find google, find a picture in google, find the photo on google, picture find google, image find on google, find with photo google, image finder google online, google find with image, photo finder in google, google find image search, search using image in google, search on google with image, google server down today, google server down news

Read More Post Here

Leave a Comment

Your email address will not be published. Required fields are marked *

x