Codeforces Testing Round #3 134A - Average Numbers Solution
Problem Link: https://codeforces.com/problemset/problem/134/A
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmanir-Rahim******///
- /// Abul Hasnat Tonmoy
- /// Department of CSE,23rd batch
- /// Islamic University,Bangladesh
- ///**********ALLAH IS ALMIGHTY************///
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long n,i;
- double s=0,av;
- cin>>n;
- long long a[n+1];
- for(int i = 1 ; i <=n ; i++) cin >> a[i], s+=a[i];
- vector < long long > v;
- for ( i = 1 ; i <=n ; i++){
- s=s-a[i];
- av=s/(n-1);
- s=s+a[i];
- if(av==a[i])v.push_back(i);
- }
- if(v.size()==0)cout<<"0"<<endl<<endl;
- else {
- cout<<v.size()<<endl;
- for(auto it:v)cout<<it<<" ";
- }
- }
No comments