Both on horizontal side and vertical side, we can consider the weapon is on a uniformly accelerated motion on its two directions and G is 9.8.
Here are two formulas:
物理题,没难度,对于水平方向上的匀减速直线运动,看成反向的初速度为0的匀加速直线运动就可以了,时间也很好计算
#include<stdio.h>
#include<math.h>
int main()
{
char name[20];
double dist,v,h,f,d,m,s;
while(~scanf("%s%lf%lf%lf%lf%lf",name,&d,&f,&m,&h,&v))
{
if(f>0)
{
if(name[0]=='F')
s=h*(2*v/9.8)+(2*f*v*v)/(9.8*9.8);
else
s=(2*f*v*v)/(9.8*9.8);
}
else
{
if(name[0]=='M')
s=h*(2*v/9.8)-(2*f*v*v)/(9.8*9.8);
else
s=-(2*f*v*v)/(9.8*9.8);
}
if(fabs(s-d)<2.0) printf("YES\n");
else printf("NO\n");
}
return 0;
}