Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
#include <vector>
int main(){
long n(0); scanf("%ld", &n);
long *array = new long[n];
long total(0);
for(long k = 0; k < n; k++){scanf("%ld", array + k); total += array[k];}
std::vector<long> indices;
for(long k = 0; k < n; k++){if(array[k] * n == total){indices.push_back(k);}}
printf("%ld\n", indices.size());
for(long k = 0; k < indices.size(); k++){printf("%ld ", 1 + indices[k]);}
puts("");
return 0;
}
Copy The Code &
Try With Live Editor
Input
5
1 2 3 4 5
1 2 3 4 5
Output
1
3
3
Demonstration
Codeforces Solution-A. Average Numbers-Solution in C, C++, Java, Python