三分 HDU 5144
#include<stdio.h> #include<algorithm> #include<string.h> #include<math.h> using namespace std; #define g 9.8 const double pi = 4*atan(1.0); double v,h; double f(double a) { return v*cos(a)*v*sin(a)/g+v*cos(a)*sqrt(v*v*sin(a)*sin(a)/g/g+2*h/g); } int main() { int t; scanf("%d",&t); while(t--) { scanf("%lf%lf",&h,&v); double l,r; l=0; r=pi/2; while(r-l>=1e-10) { double lm,rm; lm=l+(r-l)/3; rm=l+(r-l)*2/3; if(f(lm)>f(rm)) r=rm; else l=lm; } printf("%.2lf\n",f(l)); } return 0; }
posted on 2017-01-30 19:07 HelloWorld!--By-MJY 阅读(113) 评论(0) 编辑 收藏 举报