Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int p, q, r, s, t, u;
- double solve(double x)
- {
- double val=p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u;
- return val;
- }
- int main()
- {
- // freopen("INPUT.txt", "r", stdin);
- // freopen("OUTPUT.txt", "w", stdout);
- while(scanf("%d%d%d%d%d%d", &p,&q,&r,&s,&t,&u)!=EOF){
- double left=solve(0);
- double right=solve(1.0);
- if((left*right)>0)
- printf("No Solution\n");
- else{
- double l=0.0;
- double h=1.0;
- double ans;
- for(int i=0;i<100;i++){
- double mid=(l+h)/2.0;
- double key=solve(mid);
- if(key>0){
- l=mid;
- }
- else
- h=mid;
- }
- printf("%.4lf\n", l);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment