Advertisement
Manh_LK

Make them equal

Mar 14th, 2020
1,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     //freopen("input.txt", "r", stdin);
  6.     int testCase, n;
  7.     cin >> testCase;
  8.     for (int tc = 1; tc <= testCase; tc++)
  9.     {
  10.         cin >> n;
  11.         int* a = new int[n];
  12.         int sum = 0;
  13.         double average = 0;
  14.         for (int i = 0; i < n; i++)
  15.         {
  16.             cin >> a[i];
  17.             sum += a[i];
  18.         }
  19.         average = sum * 1.0 / n;
  20.         if (average == (int)average) cout << n << endl;
  21.         else cout << (n-1) << endl;
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement