仅以此文怀念高中时代,还有那次高考。
http://acm.hdu.edu.cn/showproblem.php?pid=2529
设出手速度与水平方向夹角为theta,由水平方向和垂直方向速度分解得(H为最大高度):
消去t,得:
三角代换得:
故形成tan(theta)的一元二次方程:
故最大值:
所以不难写出代码。晚上再码,该去上高数了。
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
double h, l ,v;
while(cin>>h>>l>>v && (h || l || v))
{
double s = -9.8*l*l/(2*v*v) - l*l/(2.0*(-9.8*l*l)/(v*v)) + h;
cout<<fixed<<setprecision(2)<<s<<endl;
}
}