fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. double a;
  7. cin >> n;
  8. double s = 0.0;
  9. for (int i = 0; i < n; i++){
  10. cin >> a;
  11. for(int j = 1; j<=i; j++){
  12. a/= j*1.0;
  13. }
  14. s+=a;
  15. }
  16. cout << s <<"\n";
  17. return 0;
  18. }
Success #stdin #stdout 0s 3232KB
stdin
3 6 9 3
stdout
16.5