fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. double x, e; //Переменная и погрешность
  7. scanf("%lf %le", &x, &e);
  8. double curr = (1./4.)*log((1.+x)/(1.-x)) + (1./2.)*atan(x); //Левая часть выражения
  9. int count = 0; //Счетчик
  10. double y = x; //i-тый слагаемое
  11. double sum = x; //Сумма
  12. for(; fabs(sum-curr) > e; count++){
  13. double n = (4.*count+1.)/(4.*count+5.);
  14. y = y*x*x*x*x*n;
  15. sum += y;
  16. }
  17. count++;
  18. printf("%d", count);
  19. return 0;
  20. }
Success #stdin #stdout 0s 3300KB
stdin
0.99 1e-4
stdout
148