Advertisement
Farjana_akter

Untitled

Feb 2nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define eps 1e-7
  4. int p,q,r,s,t,u;
  5.  
  6. double solve(double x)
  7. {
  8. return p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u;
  9. }
  10. int main()
  11. {
  12. double ans,lo,hi,mid;
  13. while(scanf("%d %d %d %d %d %d",&p,&q,&r,&s,&t,&u)!=EOF)
  14. {
  15. lo=0.0,hi=1.0;
  16. if(solve(lo)*solve(hi)>0)
  17. cout<<"No solution"<<endl;
  18. else
  19. {
  20. while(hi-lo>eps)
  21. {
  22. mid=(lo+hi)/2;
  23. if(solve(lo)*solve(mid)<=0)
  24. hi=mid;
  25. else
  26. lo=mid;
  27. }
  28. printf("%.4lf\n",lo);
  29. }
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement