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