[luoguP1033] 自由落体(模拟?)

传送门

这不能算是数论题。。。

卡精度这事noip也做的出来。。

代码

#include <cmath>
#include <cstdio>

int n, ans;
double h, s1, v, l, k, r = 0.0001;

inline bool check(double x)
{
	double t1 = sqrt((h - k - r) / 5.0), t2 = sqrt(h / 5.0);
	double t3 = (s1 - x - r) / v, t4 = (s1 - x + l + r) / v;
	if(t1 > t4 || t2 < t3) return 0;
	return 1;
}

int main()
{
	scanf("%lf %lf %lf %lf %lf %d", &h, &s1, &v, &l, &k, &n);
	for(int i = 0; i < n; i++) ans += check(i);
	printf("%d
", ans);
	return 0;
}

  

原文地址:https://www.cnblogs.com/zhenghaotian/p/7089973.html