hdu 2529 Shot

来源:互联网 发布:安卓电池电量优化 编辑:程序博客网 时间:2024/05/21 14:05

物理题 好题

开始看题时,就郁闷为什么没有给出速度的方向 原来要求得就是这个角度

公式

v*cos(thta)*t=l;

v*sin(thta)*t-0.5*g*t^2=h;

前式代入后式 得到关于 tan(thta)的一个二元一次方程  h(max)=0.5*v*v/g-0.5*g*l*l/(v*v);

 

#include<stdio.h>int main(){double h,l,v,g=9.8;while(scanf("%lf%lf%lf",&h,&l,&v)!=EOF){if(h==0&&l==0&&v==0)return 0;printf("%.2lf\n",(0.5*v*v/g-0.5*g*l*l/(v*v)+h));}return 0;}