NOJ [1063] Fleabag VS. Mutt

We consider that Fleabag and Mutt are on the same height and they have a distance D. The wind resistance is F (If F < 0, the wind is from Mutt to Fleabag, or it will be from Fleabag to Mutt). Fleabag or Mutt will give their hidden weapon an initial velocity (both horizontal and vertical).

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:
a = F / m
s = v0t + (1/2)(at^2)
If the weapon hit the area that the distance to another one is less than 2.0, we consider it hit another one.



物理题,没难度,对于水平方向上的匀减速直线运动,看成反向的初速度为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;
}



你可能感兴趣的:(NOJ [1063] Fleabag VS. Mutt)