三分角度....
2 0 1 1 2
0.10 0.99HintIf the height of NPY is 0,and he throws the shot at the 45° angle, he can throw farthest.
/* *********************************************** Author :CKboss Created Time :2014年12月13日 星期六 23时27分32秒 File Name :C.cpp ************************************************ */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <cstdlib> #include <vector> #include <queue> #include <set> #include <map> #include <cmath> using namespace std; const double eps=1e-6; const double g=9.8; double H,V; double Distan(double degree) { double vx=V*sin(degree); double vy=V*cos(degree); double time = ( vx+sqrt(vx*vx+2*g*H) ) / g; return time*vy; } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T_T; scanf("%d",&T_T); while(T_T--) { scanf("%lf%lf",&H,&V); double low=0.,high=90.; double mid1,mid2,ans=0; while(fabs(high-low)>=eps) { mid1=(low*2+high)/3.; mid2=(low+high*2)/3.; double len1=Distan(mid1); double len2=Distan(mid2); ans=max(ans,max(len1,len2)); if(len2+eps>len1) low=mid1; else high=mid2; } printf("%.2lf\n",ans); } return 0; }