//\\__ hr1212 __//\\
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
#define eps 0.00000000000000001
int i,n,m,a[MAX];
double y,p,q,r,s,t,u,x,z;
double dfn(double x){
return (-p)*exp(-x)+q*cos(x)-r*sin(x)+s/(cos(x)*cos(x))+2*t*x;
}
double fn(double x){
return p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u;
}
int main(){
while(scanf("%lf %lf %lf %lf %lf %lf",&p,&q,&r,&s,&t,&u)!=EOF){
z=1;
if(fn(0)==0)
printf("0.0000\n");
else{
f(i,0,50){
if(dfn(z)==0){
z=2;
break;
}
y=z-fn(z)/dfn(z);
z=y;
}
if(z<0 || z>1)
printf("No solution\n");
else
printf("%.4lf\n",z);
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
#define eps 0.00000000000000001
int i,n,m,a[MAX];
double y,p,q,r,s,t,u,x,z;
double dfn(double x){
return (-p)*exp(-x)+q*cos(x)-r*sin(x)+s/(cos(x)*cos(x))+2*t*x;
}
double fn(double x){
return p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u;
}
int main(){
while(scanf("%lf %lf %lf %lf %lf %lf",&p,&q,&r,&s,&t,&u)!=EOF){
z=1;
if(fn(0)==0)
printf("0.0000\n");
else{
f(i,0,50){
if(dfn(z)==0){
z=2;
break;
}
y=z-fn(z)/dfn(z);
z=y;
}
if(z<0 || z>1)
printf("No solution\n");
else
printf("%.4lf\n",z);
}
}
return 0;
}
No comments:
Post a Comment