Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define eps 1e-7
- int p,q,r,s,t,u;
- double solve(double x)
- {
- return p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u;
- }
- int main()
- {
- double ans,lo,hi,mid;
- while(scanf("%d %d %d %d %d %d",&p,&q,&r,&s,&t,&u)!=EOF)
- {
- lo=0.0,hi=1.0;
- if(solve(lo)*solve(hi)>0)
- cout<<"No solution"<<endl;
- else
- {
- while(hi-lo>eps)
- {
- mid=(lo+hi)/2;
- if(solve(lo)*solve(mid)<=0)
- hi=mid;
- else
- lo=mid;
- }
- printf("%.4lf\n",lo);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement