Saleh127

uva 10341.cpp

Jun 8th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. #define ep 1e-7
  7. double p,q,r,s,t,u;
  8. double fun(double x)
  9. {
  10. return p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u;
  11. }
  12. double findvlu()
  13. {
  14. double mid;
  15. double lo=0.0,hi=1.0;
  16. while(lo+ep<hi)
  17. {
  18. mid=(lo+hi)/2.0;
  19. double ans=fun(mid);
  20. if(ans>0)
  21. {
  22. lo=mid;
  23. }
  24. else hi=mid;
  25. }
  26. return mid;
  27. }
  28. int main()
  29. {
  30. Faster
  31. while(cin>>p>>q>>r>>s>>t>>u)
  32. {
  33. if(fun(0)*fun(1)>0)
  34. {
  35. printf("No solution\n");
  36. }
  37. else
  38. {
  39. printf("%.4lf\n",findvlu());
  40. }
  41. }
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment