fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int n, tmp;
  5. double ans, num ;
  6. cin >> n;
  7. ans = 0.0;
  8.  
  9. for (int i = 1; i <= n; i++) {
  10. double ii = 1.0 * i;
  11. cin >> tmp;
  12. num = 1.0 / ii;
  13. ans = (ans + num);
  14. }
  15.  
  16. cout << fixed << setprecision(6) << ans << "\n";
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 4856KB
stdin
Standard input is empty
stdout
0.000000