Advertisement
awsmpshk

Untitled

Jan 16th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <algorithm>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. double eps;
  10. cin >> eps;
  11. double sum = 0, elem = 0.5;
  12. while (abs(elem) >= eps) {
  13. sum += elem;
  14. elem /= 2;
  15. }
  16. cout << fixed << setprecision(6);
  17. cout << sum + elem << endl;
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement