Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<cmath>
- using namespace std;
- double p, q, r, s, t, u;
- float sol(float x)
- {
- return p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*pow(x,2.0)+u;
- }
- int main()
- {
- while(scanf("%lf %lf %lf %lf %lf %lf",&p,&q,&r,&s,&t,&u)!=EOF){
- double l=0,m=0.5,h=1,xm,xh;
- while(h-l>0.0000001){
- m=(l+h)/2;
- xm=sol(m);
- xh=sol(h);
- if((xh<0 && xm>0)||(xh>=0 && xm>xh)||(xh<=0 && xh>xm)){
- l=m;
- }
- else{
- h=m;
- }
- }
- if(abs(xm)<=0.0001)
- printf("%1.4f\n",m);
- else
- printf("No solution\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement