[hdu 2298] 物理推导+二分答案

时间:2021-06-12 21:02:01

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2298

[hdu 2298] 物理推导+二分答案

[hdu 2298] 物理推导+二分答案

#include<bits/stdc++.h>
using namespace std; const double pi=acos(-1.0);
const double g=9.8;
const double eps=1e-; int main()
{
int t;
scanf("%d",&t);
while (t--)
{
double x,y,v;
scanf("%lf%lf%lf",&x,&y,&v);
double tant=v*v/g/x;
double theta=atan(tant);
double sint=sin(theta);
double cost=cos(theta);
double ymax=x*tant-g*x*x/2.0/v/v/cost/cost;
if (ymax<y) printf("-1\n");
else
{
double l=,r=theta;
while (r-l>eps)
{
double mid=(l+r)/2.0;
double tanm=tan(mid);
double cosm=cos(mid);
double ym=x*tanm-g*x*x/2.0/v/v/cosm/cosm;
if (ym>=y) r=mid;
else l=mid;
}
printf("%.6f\n",l);
}
}
return ;
}