[hdu2298] 物理推導+二分答案
阿新 • • 發佈:2017-07-17
right its get pro name clu href ace atan
題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=2298
#include<bits/stdc++.h> using namespace std; const double pi=acos(-1.0); const double g=9.8; const double eps=1e-9; 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=0,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 0; }
[hdu2298] 物理推導+二分答案