Codeforces Testing Round #3 134A - Average Numbers Solution


 

Problem Link: https://codeforces.com/problemset/problem/134/A

Solution in C++:

  1. /// La ilaha illellahu muhammadur rasulullah
  2. ///******Bismillahir-Rahmanir-Rahim******///
  3. /// Abul Hasnat Tonmoy
  4. /// Department of CSE,23rd batch
  5. /// Islamic University,Bangladesh
  6. ///**********ALLAH IS ALMIGHTY************///
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9. int main()
  10. {
  11. long long n,i;
  12. double s=0,av;
  13. cin>>n;
  14. long long a[n+1];
  15. for(int i = 1 ; i <=n ; i++) cin >> a[i], s+=a[i];
  16. vector < long long > v;
  17. for ( i = 1 ; i <=n ; i++){
  18. s=s-a[i];
  19. av=s/(n-1);
  20. s=s+a[i];
  21. if(av==a[i])v.push_back(i);
  22. }
  23. if(v.size()==0)cout<<"0"<<endl<<endl;
  24. else {
  25. cout<<v.size()<<endl;
  26. for(auto it:v)cout<<it<<" ";
  27. }
  28. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.