Scorched Earth--HOJ 11892

1、题目类型:数论、物理。

2、解题思路:(1)根据物理公式S=V*t+0.5*a*t*t 换代求的t、v的表达式;(2)据题意条件输出。

3、注意事项:注意0.0 ≤Xu < Xo ≤1000.0 and 0.0 ≤Yu, Yo ≤800.0.这样题意确定了shot轨迹,而不用考虑多种情况;Pi 的精度需控制在1E-9左右;输出判断时候注意never exceed 300.0 m/s否则WA。

3、实现方法:

  
    
#include < iostream >
#include
< math.h >
using namespace std;
#define g 9.8
#define Pi 3.14159265358

int main()
{
int n;
cin
>> n;
double x0,y0,x1,y1,a,d,v,t;
while (n -- )
{
cin
>> x0 >> y0 >> x1 >> y1 >> a >> d;
d
= d * Pi / 180.0 ;
t
= sqrt( 2.0 * ((x1 - x0) - (y1 - y0) / tan(d) ) / (a + g / tan(d)) );
v
= ( - 0.5 * a * t * t + (x1 - x0)) / (t * cos(d));
if (v >= 0 && v <= 300.0 )
printf(
" %.5lf\n " ,v);
else
printf(
" impossible\n " );
}
return 0 ;
}

 

你可能感兴趣的:(sc)