2004
3<br>0.222018 23.901887 121.909183<br>39.096669 110.210922 20.270030<br>138.355025 2028.716904 25.079551<br>
1.561582<br>-1<br>-1<br>
AC代码:
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#define PI acos(-1.0)
#define G 9.8
#define eps 1e-12
using namespace std;
double X,Y,v,sita;
double cal(double x)
{
double t;
t=X/(v*cos(x));
return v*sin(x)*t-0.5*G*t*t;
}
double triplediv()
{
int i;
double mid1,mid2,left,right,h1,h2;
left=0,right=0.5*PI;
for(i=1;i<=100;i++)
{
mid1=(2*left+right)/3;
mid2=(left+2*right)/3;
h1=cal(mid1);
h2=cal(mid2);
if(h1>h2)
{
right=mid2;
}
else
{
left=mid1;
}
}
sita=left;
return cal(left);
}
void doublediv(double maxy)
{
int i;
double left,right,mid,h;
left=0,right=sita;
for(i=1;i<=100;i++)
{
mid=(left+right)/2;
h=cal(mid);
if(h>Y)
right=mid;
else
left=mid;
}
printf("%.6lf\n",left);
}
int main()
{
int t;
double maxy;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf",&X,&Y,&v);
maxy=triplediv();
if(maxy<Y)
printf("-1\n");
else
doublediv(maxy);
}
return 0;
}