Advertisement
a53

MediePrime

a53
Jan 16th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #define NN 10001
  5. using namespace std;
  6.  
  7. int n,v[NN];
  8.  
  9. int main()
  10. {
  11. v[0]=v[1]=1;
  12. for(int i=2;i*i<NN;++i)
  13. if(v[i]==0)
  14. for(int j=2;i*j<NN;++j)
  15. v[i*j]=1;
  16. cin>>n;
  17. int x,nr=0;
  18. double s=0;
  19. for(int i=1;i<=n;++i)
  20. {
  21. cin>>x;
  22. if(v[x]==0)
  23. s+=x,++nr;
  24. }
  25. cout<<fixed<<setprecision(2)<<trunc(s/nr*100)/100;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement