题目链接:https://www.luogu.org/problemnew/show/P1033
呵呵,真的学好物理比较重要,前些年卡在这题上的我今天终于会做了,可恶的自由落体(也许是我太弱了吧 )
分析:
这道题似乎并不用特意在乎精度,只是提醒大家一点:能全用double尽量都用,这样能避免中间转换是不必要的精度问题。 公式的推导相信大家都会吧,这里不再赘述,也会在代码中详细说明。 下面见代码
代码:
#include<cstdio>
#include<cmath>
using namespace std
;
int main()
{
double h
,s1
,v
,l
,k
,n
;
scanf("%lf%lf%lf%lf%lf%lf",&h
,&s1
,&v
,&l
,&k
,&n
);
double Maxtime
=sqrt(h
/5);
double Mintime
=sqrt((h
-k
)/5);
int s
=int(s1
-Mintime
*v
+l
);
int e
=int(s1
-Maxtime
*v
);
s
=fmin(s
,n
);
e
=fmax(e
,0);
printf("%d",s
-e
);
return 0;
}
撒花
~
转载于:https://www.cnblogs.com/vercont/p/10210039.html
相关资源:JAVA上百实例源码以及开源项目