Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- double p,q,r,s,t,u;
- bool valid(double x)
- {
- return (p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u)>0;
- }
- int main(){
- while(cin>>p>>q>>r>>s>>t>>u){
- if(p*exp(-1)+q*sin(1)+r*cos(1)+s*tan(1)+t+u>1e-12||p+r+u<0){
- printf("No solution\n");
- continue;
- }
- double s=0, e=1;
- while(fabs(e-s)>1e-15)
- {
- double mid=(s+e)/2;
- if(valid(mid)) s=mid;
- else e=mid;
- }
- printf("%.4f\n",s);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment