fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector <long double> x;
  7. int n;
  8. long double ans=0;
  9. cin >> n;
  10. x.resize(n);
  11. for(int i=0; i<n; i++)
  12. {
  13. cin >> x[i];
  14. }
  15. for(int i=0; i<n; i++)
  16. {
  17. ans+=x[i]+1.0/x[i];
  18. }
  19. cout.precision(15);
  20. cout << fixed << ans;
  21. return 0;
  22. }
Success #stdin #stdout 0s 4268KB
stdin
1
10
stdout
10.100000000000000